Class: Pio::Match

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/pio/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



153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/pio/match.rb', line 153

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".intern] = true
    end
  end
  @format = MatchFormat.new({ wildcards: flags }.merge user_options)
end

Class Method Details

.read(binary) ⇒ Object



126
127
128
# File 'lib/pio/match.rb', line 126

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

Instance Method Details

#==(other) ⇒ Object

rubocop:enable MethodLength



168
169
170
171
# File 'lib/pio/match.rb', line 168

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