Make ByteBuffer work no matter what the string encoding scheme.

This commit is contained in:
Jim Menard 2009-01-21 12:09:18 -05:00
parent 3e33811425
commit cc7cac680b
2 changed files with 9 additions and 17 deletions

View File

@ -66,14 +66,10 @@ class ByteBuffer
@cursor += array.length
end
if RUBY_VERSION >= '1.9'
def put_int(i, offset=nil)
put_array([i].pack(@int_pack_order).split(//).collect{|c| c.bytes.first}, offset)
end
else
def put_int(i, offset=nil)
put_array([i].pack(@int_pack_order).split(//).collect{|c| c[0]}, offset)
end
def put_int(i, offset=nil)
a = []
[i].pack(@int_pack_order).each_byte { |b| a << b }
put_array(a, offset)
end
def put_long(i, offset=nil)
@ -87,14 +83,10 @@ class ByteBuffer
end
end
if RUBY_VERSION >= '1.9'
def put_double(d, offset=nil)
put_array([d].pack(@double_pack_order).split(//).collect{|c| c.bytes.first}, offset)
end
else
def put_double(d, offset=nil)
put_array([d].pack(@double_pack_order).split(//).collect{|c| c[0]}, offset)
end
def put_double(d, offset=nil)
a = []
[d].pack(@double_pack_order).each_byte { |b| a << b }
put_array(a, offset)
end
# If +size+ == nil, returns one byte. Else returns array of bytes of length

View File

@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'mongo'
s.version = '0.2.1'
s.version = '0.2.2'
s.platform = Gem::Platform::RUBY
s.summary = 'Simple pure-Ruby driver for the 10gen Mongo DB'
s.description = 'A pure-Ruby driver for the 10gen Mongo DB. For more information about Mongo, see http://www.mongodb.org.'