Class: Lunar::RangeMatches

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#attObject (readonly)

Returns the value of attribute att.



8
9
10
# File 'lib/lunar/range_matches.rb', line 8

def att
  @att
end

#nestObject (readonly)

Returns the value of attribute nest.



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

def nest
  @nest
end

#rangeObject (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

#distkeyObject



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