Class: OpenFlow::Protocol::ArrayOfSubclasses

Inherits:
BinData::Primitive
  • Object
show all
Defined in:
lib/openflow-protocol/helpers/array_of_subclasses.rb

Direct Known Subclasses

Actions, QueueProperties

Instance Method Summary collapse

Instance Method Details

#getObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/openflow-protocol/helpers/array_of_subclasses.rb', line 10

def get
  items = []
  tmp = binary
  until tmp.empty?
    type_index = BinData::Uint16be.read(tmp)
    type_str = types.fetch(type_index)
    class_name = name + type_str.to_s.split('_').map(&:capitalize).join
    klass = OpenFlow::Protocol.const_get class_name
    item = klass.read(tmp)
    items << item
    tmp = tmp[item.len..-1]
  end
  items
end

#set(value) ⇒ Object



25
26
27
# File 'lib/openflow-protocol/helpers/array_of_subclasses.rb', line 25

def set(value)
  self.binary = value.map(&:to_binary_s).join
end