Class: Instruction
- Inherits:
-
Object
- Object
- Instruction
- Defined in:
- lib/openflowdev/instruction.rb
Overview
Class representing OpenFlow flow instruction
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Action : list of Action.
-
#order ⇒ Object
integer : order that action is to be carried out relative to other instructions.
Instance Method Summary collapse
-
#add_apply_action(action) ⇒ Object
Add action to an Instruction.
-
#initialize(instruction_order: nil) ⇒ Instruction
constructor
- Parameters *
instruction_order -
Order in which to carry out this instruction relative to other instructions.
- Parameters *
-
#to_hash ⇒ Object
:nodoc:.
Constructor Details
#initialize(instruction_order: nil) ⇒ Instruction
Parameters
instruction_order-
Order in which to carry out this instruction relative to other instructions.
41 42 43 44 45 |
# File 'lib/openflowdev/instruction.rb', line 41 def initialize(instruction_order: nil) raise ArgumentError, "Instruction Order (instruction_order) required" unless instruction_order @order = instruction_order @actions = [] end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Action : list of Action
36 37 38 |
# File 'lib/openflowdev/instruction.rb', line 36 def actions @actions end |
#order ⇒ Object
integer : order that action is to be carried out relative to other instructions.
34 35 36 |
# File 'lib/openflowdev/instruction.rb', line 34 def order @order end |
Instance Method Details
#add_apply_action(action) ⇒ Object
Add action to an Instruction.
Parameters
action-
Action : What action to take
52 53 54 55 |
# File 'lib/openflowdev/instruction.rb', line 52 def add_apply_action(action) raise ArgumentError, "Action must be a subclass of 'Action'" unless action.is_a?(Action) @actions << action end |
#to_hash ⇒ Object
:nodoc:
57 58 59 60 61 62 63 |
# File 'lib/openflowdev/instruction.rb', line 57 def to_hash #:nodoc: actions_hash = [] @actions.each do |action| actions_hash << action.to_hash end {:order => @order, 'apply-actions' => {:action => actions_hash}} end |