Class: CaseGen::Combination
- Inherits:
-
Object
- Object
- CaseGen::Combination
- Defined in:
- lib/case_gen/combination.rb
Instance Attribute Summary collapse
-
#excluded_by_rule ⇒ Object
readonly
Returns the value of attribute excluded_by_rule.
-
#names ⇒ Object
readonly
Returns the value of attribute names.
Instance Method Summary collapse
- #append(key, value) ⇒ Object
- #exclude_with(rule) ⇒ Object
- #excluded? ⇒ Boolean
- #hash_row ⇒ Object
-
#initialize(hash_pairs) ⇒ Combination
constructor
A new instance of Combination.
Constructor Details
#initialize(hash_pairs) ⇒ Combination
Returns a new instance of Combination.
7 8 9 10 11 12 13 14 |
# File 'lib/case_gen/combination.rb', line 7 def initialize(hash_pairs) @names = hash_pairs.map do |h| k = h.first.first v = h.first.last append(k, v) k end end |
Instance Attribute Details
#excluded_by_rule ⇒ Object (readonly)
Returns the value of attribute excluded_by_rule.
5 6 7 |
# File 'lib/case_gen/combination.rb', line 5 def excluded_by_rule @excluded_by_rule end |
#names ⇒ Object (readonly)
Returns the value of attribute names.
5 6 7 |
# File 'lib/case_gen/combination.rb', line 5 def names @names end |
Instance Method Details
#append(key, value) ⇒ Object
24 25 26 27 28 |
# File 'lib/case_gen/combination.rb', line 24 def append(key, value) @names << key if defined?(@names) instance_variable_set("@#{key}", value) self.class.attr_accessor key end |
#exclude_with(rule) ⇒ Object
30 31 32 |
# File 'lib/case_gen/combination.rb', line 30 def exclude_with(rule) @excluded_by_rule = rule end |
#excluded? ⇒ Boolean
34 35 36 |
# File 'lib/case_gen/combination.rb', line 34 def excluded? !@excluded_by_rule.nil? end |
#hash_row ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/case_gen/combination.rb', line 16 def hash_row {}.tap do |h| @names.each do |ivar| h[ivar] = instance_variable_get("@#{ivar}") end end end |