Class: Lunar::RangeMatches
- Inherits:
-
Object
- Object
- Lunar::RangeMatches
- Defined in:
- lib/lunar/range_matches.rb
Overview
given ‘nest`, `att` and it’s ‘val`.
Constant Summary collapse
- MAX_RESULTS =
10_000
Instance Attribute Summary collapse
-
#att ⇒ Object
readonly
Returns the value of attribute att.
-
#nest ⇒ Object
readonly
Returns the value of attribute nest.
-
#range ⇒ Object
readonly
Returns the value of attribute range.
Instance Method Summary collapse
- #distkey ⇒ Object
-
#initialize(nest, att, range) ⇒ RangeMatches
constructor
A new instance of RangeMatches.
Constructor Details
#initialize(nest, att, range) ⇒ RangeMatches
Returns a new instance of RangeMatches.
11 12 13 |
# File 'lib/lunar/range_matches.rb', line 11 def initialize(nest, att, range) @nest, @att, @range = nest, att.to_sym, range end |
Instance Attribute Details
#att ⇒ Object (readonly)
Returns the value of attribute att.
8 9 10 |
# File 'lib/lunar/range_matches.rb', line 8 def att @att end |
#nest ⇒ Object (readonly)
Returns the value of attribute nest.
7 8 9 |
# File 'lib/lunar/range_matches.rb', line 7 def nest @nest end |
#range ⇒ Object (readonly)
Returns the value of attribute range.
9 10 11 |
# File 'lib/lunar/range_matches.rb', line 9 def range @range end |
Instance Method Details
#distkey ⇒ Object
16 17 18 19 20 21 |
# File 'lib/lunar/range_matches.rb', line 16 def distkey nest[{ att => range }.hash].tap do |dk| res = zset.zrangebyscore(range.first, range.last, :limit => [0, MAX_RESULTS]) res.each { |val| dk.zadd(1, val) } end end |