Class: BinaryStruct

Inherits:
Object
  • Object
show all
Defined in:
lib/VolumeManager/MiqLdm.rb

Class Method Summary collapse

Class Method Details

.stepDecode(data, format) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/VolumeManager/MiqLdm.rb', line 11

def self.stepDecode(data, format)
  type = format[0, 1]
  raise "unrecognized format: #{type}" if SIZES.key?(type) == false
  raise "unsupported  format: #{type}" if SIZES[type].nil?

  count = (format.size > 1) ? format[1, format.size - 1].to_i : 1
  raise "unsupported count: #{count}" if count.kind_of?(Numeric) == false

  size = (count * SIZES[type])

  data.slice!(0, size).unpack(format)[0]
end