Class: FakeRedis::ZSet

Inherits:
Hash
  • Object
show all
Defined in:
lib/fakeredis/zset.rb

Instance Method Summary collapse

Instance Method Details

#[]=(key, val) ⇒ Object



4
5
6
# File 'lib/fakeredis/zset.rb', line 4

def []=(key, val)
  super(key, _floatify(val))
end

#identical_scores?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/fakeredis/zset.rb', line 8

def identical_scores?
  values.uniq.size == 1
end

#increment(key, val) ⇒ Object

Increments the value of key by val



13
14
15
# File 'lib/fakeredis/zset.rb', line 13

def increment(key, val)
  self[key] += _floatify(val)
end

#select_by_score(min, max) ⇒ Object



17
18
19
20
21
# File 'lib/fakeredis/zset.rb', line 17

def select_by_score min, max
  min = _floatify(min, true)
  max = _floatify(max, false)
  select {|_,v| v >= min && v <= max }
end