Class: OFActions

Inherits:
BinData::Primitive
  • Object
show all
Defined in:
lib/actions/actions.rb

Instance Method Summary collapse

Instance Method Details

#getObject



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

def get
  actions = []
  tmp = binary
  until tmp.empty?
    type_index = BinData::Uint16be.read(tmp)
    type_str = OFAction::TYPES.fetch(type_index)
    class_name = 'OFAction' + type_str.to_s.split('_').map(&:capitalize).join
    klass = Object.const_get class_name
    action = klass.read(tmp)
    actions << action
    tmp = tmp[action.len..-1]
  end
  actions
end

#set(value) ⇒ Object



25
26
27
# File 'lib/actions/actions.rb', line 25

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