Class: Pio::OpenFlow10::Match

Inherits:
Pio::OpenFlow::FlowMatch show all
Defined in:
lib/pio/open_flow10/match.rb

Overview

Fields to match against flows

Defined Under Namespace

Classes: MatchFormat, MatchIpAddress, Wildcards

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_options = {}) ⇒ Match

rubocop:disable MethodLength This method smells of :reek:FeatureEnvy This method smells of :reek:DuplicateMethodCall



138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/pio/open_flow10/match.rb', line 138

def initialize(user_options = {})
  flags = Wildcards::FLAGS.each_with_object({}) do |each, memo|
    memo[each] = true unless user_options.key?(each)
  end
  Wildcards::NW_FLAGS.each_with_object(flags) do |each, memo|
    if user_options.key?(each)
      memo[each] = 32 - IPv4Address.new(user_options[each]).prefixlen
    else
      memo["#{each}_all".to_sym] = true
    end
  end
  @format = MatchFormat.new({ wildcards: flags }.merge(user_options))
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



162
163
164
# File 'lib/pio/open_flow10/match.rb', line 162

def method_missing(method, *args, &block)
  @format.__send__ method, *args, &block
end

Class Method Details

.read(binary) ⇒ Object



131
132
133
# File 'lib/pio/open_flow10/match.rb', line 131

def self.read(binary)
  MatchFormat.read binary
end

Instance Method Details

#==(other) ⇒ Object



157
158
159
160
# File 'lib/pio/open_flow10/match.rb', line 157

def ==(other)
  return false unless other
  to_binary == other.to_binary
end

#to_binaryObject

rubocop:enable MethodLength



153
154
155
# File 'lib/pio/open_flow10/match.rb', line 153

def to_binary
  @format.to_binary_s
end