Class: BIL::Unpacker
- Inherits:
-
Object
- Object
- BIL::Unpacker
- Defined in:
- lib/bil/unpacker.rb
Instance Method Summary collapse
-
#initialize(&unpack) ⇒ Unpacker
constructor
A new instance of Unpacker.
- #unpack(io) ⇒ Object
Constructor Details
#initialize(&unpack) ⇒ Unpacker
Returns a new instance of Unpacker.
3 4 5 6 |
# File 'lib/bil/unpacker.rb', line 3 def initialize(&unpack) @unpack = unpack @carry = 0 end |
Instance Method Details
#unpack(io) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/bil/unpacker.rb', line 8 def unpack(io) io.each_char.reduce(true) do |first_iteration, c| n = TABLE.index(c) next if n.nil? break if !first_iteration && n == 16 increment_carry(n) integer_complete if (n & 16) == 0 false end finalize end |