Class: CaseGen::ExcludeRule
- Inherits:
-
Object
- Object
- CaseGen::ExcludeRule
- Includes:
- ComboMatcher, RuleDescription
- Defined in:
- lib/case_gen/exclude_rule.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#rule_data ⇒ Object
readonly
Returns the value of attribute rule_data.
Instance Method Summary collapse
- #apply(combos) ⇒ Object
-
#initialize(rule_data) ⇒ ExcludeRule
constructor
A new instance of ExcludeRule.
Methods included from RuleDescription
Methods included from ComboMatcher
#ignore_keys, #matches_criteria
Constructor Details
#initialize(rule_data) ⇒ ExcludeRule
Returns a new instance of ExcludeRule.
10 11 12 13 14 |
# File 'lib/case_gen/exclude_rule.rb', line 10 def initialize(rule_data) @rule_data = rule_data @description = rule_description(rule_data) @criteria = rule_data[:criteria] end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
8 9 10 |
# File 'lib/case_gen/exclude_rule.rb', line 8 def description @description end |
#rule_data ⇒ Object (readonly)
Returns the value of attribute rule_data.
8 9 10 |
# File 'lib/case_gen/exclude_rule.rb', line 8 def rule_data @rule_data end |
Instance Method Details
#apply(combos) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/case_gen/exclude_rule.rb', line 16 def apply(combos) matches = combos.select do |combo| case @criteria when String combo.instance_eval(@criteria) when Proc combo.instance_exec(&@criteria) when nil # if the rule data has keys matching the combo, then compare the # values of provided keys. matches_criteria(combo) else raise "Unknown rule criteria class: #{@criteria.class}" end end process_matches(combos, matches) end |