Class: Lunar::KeywordMatches

Inherits:
Object
  • Object
show all
Defined in:
lib/lunar/keyword_matches.rb

Overview

given ‘nest`, `att` and it’s ‘val`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nest, att, value) ⇒ KeywordMatches

Returns a new instance of KeywordMatches.



9
10
11
# File 'lib/lunar/keyword_matches.rb', line 9

def initialize(nest, att, value)
  @nest, @att, @value = nest, att.to_sym, value
end

Instance Attribute Details

#attObject (readonly)

Returns the value of attribute att.



6
7
8
# File 'lib/lunar/keyword_matches.rb', line 6

def att
  @att
end

#nestObject (readonly)

Returns the value of attribute nest.



5
6
7
# File 'lib/lunar/keyword_matches.rb', line 5

def nest
  @nest
end

#valueObject (readonly)

Returns the value of attribute value.



7
8
9
# File 'lib/lunar/keyword_matches.rb', line 7

def value
  @value
end

Instance Method Details

#distkeyObject



13
14
15
16
17
18
19
# File 'lib/lunar/keyword_matches.rb', line 13

def distkey
  return if keys.flatten.empty?

  nest[{ att => value }.hash].tap do |dk|
    dk.zunionstore keys.flatten
  end
end