Method: CTypes::Bitmap#unpack_one
- Defined in:
- lib/ctypes/bitmap.rb
#unpack_one(buf, endian: default_endian) ⇒ ::Array
convert a String containing the binary represention of a c type into the equivalent ruby type
129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/ctypes/bitmap.rb', line 129 def unpack_one(buf, endian: default_endian) value, rest = @type.unpack_one(buf, endian: @type.endian || endian) bits = [] @bits_max.times do |bit| next if value & (1 << bit) == 0 v = @bits.dry_type[bit] v = :"bit_#{v}" if v.is_a?(Integer) bits << v end [bits, rest] end |