Class: Lunar::NumberMatches
- Inherits:
-
Object
- Object
- Lunar::NumberMatches
- Defined in:
- lib/lunar/number_matches.rb
Overview
given ‘nest`, `att` and it’s ‘val`.
Instance Attribute Summary collapse
-
#att ⇒ Object
readonly
Returns the value of attribute att.
-
#nest ⇒ Object
readonly
Returns the value of attribute nest.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #distkey ⇒ Object
-
#initialize(nest, att, value) ⇒ NumberMatches
constructor
A new instance of NumberMatches.
Constructor Details
#initialize(nest, att, value) ⇒ NumberMatches
Returns a new instance of NumberMatches.
9 10 11 12 13 |
# File 'lib/lunar/number_matches.rb', line 9 def initialize(nest, att, value) @nest = nest @att = att @values = value.kind_of?(Enumerable) ? value : [value] end |
Instance Attribute Details
#att ⇒ Object (readonly)
Returns the value of attribute att.
6 7 8 |
# File 'lib/lunar/number_matches.rb', line 6 def att @att end |
#nest ⇒ Object (readonly)
Returns the value of attribute nest.
5 6 7 |
# File 'lib/lunar/number_matches.rb', line 5 def nest @nest end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
7 8 9 |
# File 'lib/lunar/number_matches.rb', line 7 def values @values end |
Instance Method Details
#distkey ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/lunar/number_matches.rb', line 15 def distkey case keys.size when 0 then nil when 1 then keys.first else nest[{ att => values }.hash].tap do |dk| dk.zunionstore keys.flatten end end end |