class Pio::OpenFlow::Actions10

Actions list.

Constants

ACTION_CLASS

Public Instance Methods

[](index) click to toggle source

rubocop:enable MethodLength

# File lib/pio/open_flow10/actions.rb, line 66
def [](index)
  get[index]
end
get() click to toggle source

rubocop:disable MethodLength This method smells of :reek:TooManyStatements

# File lib/pio/open_flow10/actions.rb, line 49
def get
  actions = []
  tmp = binary
  until tmp.empty?
    type = BinData::Uint16be.read(tmp)
    begin
      action = ACTION_CLASS.fetch(type).read(tmp)
      tmp = tmp[action.action_length..-1]
      actions << action
    rescue KeyError
      raise "action type #{type} is not supported."
    end
  end
  actions
end
set(actions) click to toggle source
# File lib/pio/open_flow10/actions.rb, line 43
def set(actions)
  self.binary = Array(actions).map(&:to_binary).join
end