class Pio::OpenFlow::Action

OpenFlow actions.

Public Class Methods

action_header(options) click to toggle source
# File lib/pio/open_flow/action.rb, line 12
def self.action_header(options)
  module_eval do
    endian :big

    uint16 :action_type, value: options.fetch(:action_type)
    uint16 :action_length, value: options.fetch(:action_length)
  end
end
method_missing(method, *args, &block) click to toggle source
# File lib/pio/open_flow/action.rb, line 27
def self.method_missing(method, *args, &block)
  begin
    const_get(:Format).__send__ method, *args, &block
  rescue NameError
    const_set :Format, Class.new(BinData::Record)
    retry
  end
  return if method == :endian || method == :virtual
  define_method(args.first) { @format.__send__ args.first }
end
new(user_options) click to toggle source
# File lib/pio/open_flow/action.rb, line 38
def initialize(user_options)
  @format = self.class.const_get(:Format).new(user_options)
end
read(raw_data) click to toggle source
# File lib/pio/open_flow/action.rb, line 21
def self.read(raw_data)
  action = allocate
  action.instance_variable_set :@format, const_get(:Format).read(raw_data)
  action
end

Public Instance Methods

to_binary() click to toggle source
# File lib/pio/open_flow/action.rb, line 42
def to_binary
  @format.to_binary_s
end