Class: Riptables::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/riptables/rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(chain) ⇒ Rule

Returns a new instance of Rule.



6
7
8
9
10
11
# File 'lib/riptables/rule.rb', line 6

def initialize(chain)
  @chain = chain
  @permutations = []
  @conditions = Condition.conditions.dup
  @versions = [4, 6]
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



15
16
17
# File 'lib/riptables/rule.rb', line 15

def action
  @action
end

#chainObject (readonly)

Returns the value of attribute chain.



18
19
20
# File 'lib/riptables/rule.rb', line 18

def chain
  @chain
end

#conditionsObject

Returns the value of attribute conditions.



16
17
18
# File 'lib/riptables/rule.rb', line 16

def conditions
  @conditions
end

#descriptionObject

Returns the value of attribute description.



13
14
15
# File 'lib/riptables/rule.rb', line 13

def description
  @description
end

#permutationsObject (readonly)

Returns the value of attribute permutations.



19
20
21
# File 'lib/riptables/rule.rb', line 19

def permutations
  @permutations
end

#ruleObject

Returns the value of attribute rule.



14
15
16
# File 'lib/riptables/rule.rb', line 14

def rule
  @rule
end

#versionsObject

Returns the value of attribute versions.



17
18
19
# File 'lib/riptables/rule.rb', line 17

def versions
  @versions
end

Instance Method Details

#dslObject



22
23
24
# File 'lib/riptables/rule.rb', line 22

def dsl
  @dsl ||= DSL::Rule.new(self)
end

#include?(conditions) ⇒ Boolean

Returns:



26
27
28
# File 'lib/riptables/rule.rb', line 26

def include?(conditions)
  @conditions.all? { |c| c.matches?(conditions) }
end

#permuted_rulesObject



30
31
32
33
34
35
36
# File 'lib/riptables/rule.rb', line 30

def permuted_rules
  if permutations.empty?
    [self]
  else
    permutations.map(&:to_rule)
  end
end