lib/qrack/transport/buffer08.rb in bunny-0.6.0 vs lib/qrack/transport/buffer08.rb in bunny-0.6.3.rc1
- old
+ new
@@ -29,11 +29,11 @@
@data << data.to_s
self
end
def length
- @data.length
+ @data.bytesize
end
def empty?
pos == length
end
@@ -152,17 +152,17 @@
lower = data & 0xffffffff
upper = (data & ~0xffffffff) >> 32
_write([upper, lower], 'NN')
when :shortstr
data = (data || '').to_s
- _write([data.length, data], 'Ca*')
+ _write([data.bytesize, data], 'Ca*')
when :longstr
if data.is_a? Hash
write(:table, data)
else
data = (data || '').to_s
- _write([data.length, data], 'Na*')
+ _write([data.bytesize, data], 'Na*')
end
when :timestamp
write(:longlong, data.to_i)
when :table
data ||= {}
@@ -177,11 +177,11 @@
table.write(:octet, 73) # 'I'
table.write(:long, value)
when Float
table.write(:octet, 68) # 'D'
# XXX there's gotta be a better way to do this..
- exp = value.to_s.split('.').last.length
+ exp = value.to_s.split('.').last.bytesize
num = value * 10**exp
table.write(:octet, exp)
table.write(:long, num)
when Time
table.write(:octet, 84) # 'T'
@@ -267,10 +267,10 @@
end
def _write data, pack = nil
data = [*data].pack(pack) if pack
@data[@pos,0] = data
- @pos += data.length
+ @pos += data.bytesize
end
end
end
-end
\ No newline at end of file
+end