Class: MooTool::Models::IMG4::PropertySequence

Inherits:
Object
  • Object
show all
Includes:
Helpers::IMG4
Defined in:
lib/mootool/models/img4/property_sequence.rb

Direct Known Subclasses

FirmwareEntry

Constant Summary

Constants included from Helpers::IMG4

Helpers::IMG4::DECODE_TAGS, Helpers::IMG4::FIRMWARE_TAGS, Helpers::IMG4::HASH_LENGTHS, Helpers::IMG4::KEY_INSTANCE_TAGS, Helpers::IMG4::KVP_TAGS, Helpers::IMG4::OCTET_TAGS, Helpers::IMG4::SEQUENCE_TAGS, Helpers::IMG4::SIGNATURE_TAGS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::IMG4

#construct, #construct_object, #decode_construct, parse_4cc

Constructor Details

#initialize(input) ⇒ PropertySequence

Returns a new instance of PropertySequence.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mootool/models/img4/property_sequence.rb', line 10

def initialize(input)
  construction = construct(input.value.first)
  @key = construction[0].to_sym
  value = construction[1]
  case value
  when Array, Hash
    @value = value
  when PropertySequence
    @value = { value.key => value.value }
  end

  return unless @value.is_a?(Array)

  @value = @value.map(&:to_h).reduce({}, :merge)
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



8
9
10
# File 'lib/mootool/models/img4/property_sequence.rb', line 8

def key
  @key
end

#valueObject (readonly)

Returns the value of attribute value.



8
9
10
# File 'lib/mootool/models/img4/property_sequence.rb', line 8

def value
  @value
end

Instance Method Details

#inspectObject



30
31
32
# File 'lib/mootool/models/img4/property_sequence.rb', line 30

def inspect
  to_h.ai
end

#to_hObject



26
27
28
# File 'lib/mootool/models/img4/property_sequence.rb', line 26

def to_h
  { @key => @value }
end