class RQRCode::QRBitBuffer
Attributes
buffer[R]
Public Class Methods
new()
click to toggle source
# File lib/rqrcode/qrcode/qr_bit_buffer.rb, line 17 def initialize @buffer = [] @length = 0 end
Public Instance Methods
get( index )
click to toggle source
# File lib/rqrcode/qrcode/qr_bit_buffer.rb, line 23 def get( index ) buf_index = (index / 8).floor (( (@buffer[buf_index]).rszf(7 - index % 8)) & 1) == 1 end
get_length_in_bits()
click to toggle source
# File lib/rqrcode/qrcode/qr_bit_buffer.rb, line 36 def get_length_in_bits @length end
put( num, length )
click to toggle source
# File lib/rqrcode/qrcode/qr_bit_buffer.rb, line 29 def put( num, length ) ( 0...length ).each do |i| put_bit((((num).rszf(length - i - 1)) & 1) == 1) end end
put_bit( bit )
click to toggle source
# File lib/rqrcode/qrcode/qr_bit_buffer.rb, line 41 def put_bit( bit ) buf_index = ( @length / 8 ).floor if @buffer.size <= buf_index @buffer << 0 end if bit @buffer[buf_index] |= ((0x80).rszf(@length % 8)) end @length += 1 end