Class: Opencdd::InstanceRule
- Inherits:
-
Object
- Object
- Opencdd::InstanceRule
- Defined in:
- lib/opencdd/instance_rule.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#exceptions ⇒ Object
readonly
Returns the value of attribute exceptions.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #expand ⇒ Object
-
#initialize(klass:, groups:, exceptions: []) ⇒ InstanceRule
constructor
A new instance of InstanceRule.
Constructor Details
#initialize(klass:, groups:, exceptions: []) ⇒ InstanceRule
Returns a new instance of InstanceRule.
10 11 12 13 14 15 |
# File 'lib/opencdd/instance_rule.rb', line 10 def initialize(klass:, groups:, exceptions: []) @klass = klass @groups = groups @exceptions = exceptions freeze end |
Instance Attribute Details
#exceptions ⇒ Object (readonly)
Returns the value of attribute exceptions.
8 9 10 |
# File 'lib/opencdd/instance_rule.rb', line 8 def exceptions @exceptions end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
8 9 10 |
# File 'lib/opencdd/instance_rule.rb', line 8 def groups @groups end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
8 9 10 |
# File 'lib/opencdd/instance_rule.rb', line 8 def klass @klass end |
Instance Method Details
#expand ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/opencdd/instance_rule.rb', line 17 def return [] if @groups.empty? per_group = @groups.map { |g| (g) } return [] if per_group.any?(&:empty?) product = per_group.reduce do |acc, rows| acc.product(rows).map { |a, b| a.merge(b) } end product.reject { |row| exception_match?(row) } .map { |row| strip_internal(row) } end |