Class: Dastbytes::Binary
- Inherits:
-
Object
- Object
- Dastbytes::Binary
- Defined in:
- lib/dastbytes/binary.rb
Class Method Summary collapse
Class Method Details
.pack(type, value) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/dastbytes/binary.rb', line 3 def self.pack( type, value ) values = [ value ] case type when :uint8 values.pack( "C*" ) when :uint16 values.pack( "v*" ) when :uint32 values.pack( "V*" ) end end |
.unpack(type, value) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dastbytes/binary.rb', line 15 def self.unpack( type, value ) case type when :uint8 value.unpack( "C*" ) when :uint16 value.unpack( "v*" ) when :uint32 value.unpack( "V*" ) end end |