Class: Riptables::Rule
- Inherits:
-
Object
- Object
- Riptables::Rule
- Defined in:
- lib/riptables/rule.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#chain ⇒ Object
readonly
Returns the value of attribute chain.
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#description ⇒ Object
Returns the value of attribute description.
-
#permutations ⇒ Object
readonly
Returns the value of attribute permutations.
-
#rule ⇒ Object
Returns the value of attribute rule.
-
#versions ⇒ Object
Returns the value of attribute versions.
Instance Method Summary collapse
- #dsl ⇒ Object
- #include?(conditions) ⇒ Boolean
-
#initialize(chain) ⇒ Rule
constructor
A new instance of Rule.
- #permuted_rules ⇒ Object
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
#action ⇒ Object
Returns the value of attribute action.
15 16 17 |
# File 'lib/riptables/rule.rb', line 15 def action @action end |
#chain ⇒ Object (readonly)
Returns the value of attribute chain.
18 19 20 |
# File 'lib/riptables/rule.rb', line 18 def chain @chain end |
#conditions ⇒ Object
Returns the value of attribute conditions.
16 17 18 |
# File 'lib/riptables/rule.rb', line 16 def conditions @conditions end |
#description ⇒ Object
Returns the value of attribute description.
13 14 15 |
# File 'lib/riptables/rule.rb', line 13 def description @description end |
#permutations ⇒ Object (readonly)
Returns the value of attribute permutations.
19 20 21 |
# File 'lib/riptables/rule.rb', line 19 def permutations @permutations end |
#rule ⇒ Object
Returns the value of attribute rule.
14 15 16 |
# File 'lib/riptables/rule.rb', line 14 def rule @rule end |
#versions ⇒ Object
Returns the value of attribute versions.
17 18 19 |
# File 'lib/riptables/rule.rb', line 17 def versions @versions end |
Instance Method Details
#dsl ⇒ Object
22 23 24 |
# File 'lib/riptables/rule.rb', line 22 def dsl @dsl ||= DSL::Rule.new(self) end |
#include?(conditions) ⇒ Boolean
26 27 28 |
# File 'lib/riptables/rule.rb', line 26 def include?(conditions) @conditions.all? { |c| c.matches?(conditions) } end |
#permuted_rules ⇒ Object
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 |