Module: Packable::Extensions::Integer::ClassMethods

Defined in:
lib/packable/extensions/integer.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#unpack_string(s, options) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/packable/extensions/integer.rb', line 36

def unpack_string(s,options)
  s = s.reverse if NEEDS_REVERSAL[options[:endian]]
  r = 0
  s.each_byte {|b| r = (r << 8) + b}
  r -= 1 << (8 * options[:bytes])  if options[:signed] && (1 == r >> (8 * options[:bytes] - 1))
  r
end