Module: Scale::Types::FixedWidthUInt::ClassMethods
- Defined in:
- lib/scale/base.rb
Instance Attribute Summary collapse
-
#byte_length ⇒ Object
Returns the value of attribute byte_length.
Instance Method Summary collapse
Instance Attribute Details
#byte_length ⇒ Object
Returns the value of attribute byte_length.
129 130 131 |
# File 'lib/scale/base.rb', line 129 def byte_length @byte_length end |
Instance Method Details
#decode(scale_bytes) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/scale/base.rb', line 131 def decode(scale_bytes) puts "BEGIN " + self::TYPE_NAME + ": #{scale_bytes}" if Scale::Types.debug == true bytes = scale_bytes.get_next_bytes self::BYTE_LENGTH bytes_reversed = bytes.reverse hex = bytes_reversed.reduce("0x") { |hex, byte| hex + byte.to_s(16).rjust(2, "0") } result = new(hex.to_i(16)) puts " END " + self::TYPE_NAME + ": #{scale_bytes}" if Scale::Types.debug == true result end |