/usr/lib/ruby/vendor_ruby/fakeredis/zset.rb is in ruby-fakeredis 0.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | module FakeRedis
class ZSet < Hash
def []=(key, val)
super(key, _floatify(val))
end
# Increments the value of key by val
def increment(key, val)
self[key] += _floatify(val)
end
def select_by_score min, max
min = _floatify(min, true)
max = _floatify(max, false)
reject {|_,v| v < min || v > max }
end
private
# Originally lifted from redis-rb
def _floatify(str, increment = true)
if (( inf = str.to_s.match(/^([+-])?inf/i) ))
(inf[1] == "-" ? -1.0 : 1.0) / 0.0
elsif (( number = str.to_s.match(/^\((\d+)/i) ))
number[1].to_i + (increment ? 1 : -1)
else
Float str
end
end
end
end
|