Module: Ohm::SortedMethods
- Included in:
- SortedSet
- Defined in:
- lib/ohm/sorted.rb
Instance Attribute Summary collapse
-
#limit(n) ⇒ Object
Returns the value of attribute limit.
-
#offset(n) ⇒ Object
Returns the value of attribute offset.
-
#range(range) ⇒ Object
Returns the value of attribute range.
Instance Method Summary collapse
Instance Attribute Details
#limit(n) ⇒ Object
Returns the value of attribute limit.
7 8 9 |
# File 'lib/ohm/sorted.rb', line 7 def limit @limit end |
#offset(n) ⇒ Object
Returns the value of attribute offset.
8 9 10 |
# File 'lib/ohm/sorted.rb', line 8 def offset @offset end |
#range(range) ⇒ Object
Returns the value of attribute range.
9 10 11 |
# File 'lib/ohm/sorted.rb', line 9 def range @range end |
Instance Method Details
#ids ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/ohm/sorted.rb', line 37 def ids if @range.nil? execute { |key| db.zrange(key, start, stop) } else execute { |key| db.zrangebyscore(key, @range.begin.to_f, @range.end.to_f, offset: [start, stop]) } end end |
#start ⇒ Object
23 24 25 |
# File 'lib/ohm/sorted.rb', line 23 def start @start ||= (@offset || 0) end |
#stop ⇒ Object
27 28 29 |
# File 'lib/ohm/sorted.rb', line 27 def stop @stop ||= (@limit.nil? ? -1 : start + @limit - 1) end |