Class: VK::P
- Inherits:
-
O
show all
- Defined in:
- lib/valkey/objects.rb
Instance Attribute Summary
Attributes inherited from O
#key
Instance Method Summary
collapse
Methods inherited from O
#initialize
Constructor Details
This class inherits a constructor from VK::O
Instance Method Details
#[](i) ⇒ Object
219
220
221
222
|
# File 'lib/valkey/objects.rb', line 219
def [] i
x = VK.redis.call("GEOPOS", key, i)[0];
return { longitude: x[0], latitude: x[1] }
end
|
#add(i, lon, lat) ⇒ Object
216
217
218
|
# File 'lib/valkey/objects.rb', line 216
def add i, lon, lat
VK.redis.call("GEOADD", key, lon, lat, i)
end
|
#distance(a, b) ⇒ Object
223
224
225
|
# File 'lib/valkey/objects.rb', line 223
def distance a, b
VK.redis.call("GEODIST", key, a, b, 'm').to_f;
end
|
#radius(lon, lat, r) ⇒ Object
226
227
228
229
230
|
# File 'lib/valkey/objects.rb', line 226
def radius lon, lat, r
h = {}
VK.redis.call("GEORADIUS", key, lon, lat, r, 'm', 'WITHDIST').each { |e| h[e[0]] = e[1].to_f };
return h
end
|
#value(&b) ⇒ Object
213
214
215
|
# File 'lib/valkey/objects.rb', line 213
def value &b
VK.redis.call("ZRANGE", key, 0, -1).each_with_index { |e, i| b.call(i, e) };
end
|