Class: VK::PLACE
- 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
#delete!, #expire, #initialize
Constructor Details
This class inherits a constructor from VK::O
Instance Method Details
#[](i) ⇒ Object
573
574
575
576
|
# File 'lib/valkey/objects.rb', line 573
def [] i
x = VK.redis.call("GEOPOS", key, i)[0];
return { longitude: x[0], latitude: x[1] }
end
|
#add(i, lon, lat) ⇒ Object
570
571
572
|
# File 'lib/valkey/objects.rb', line 570
def add i, lon, lat
VK.redis.call("GEOADD", key, lon, lat, i)
end
|
#distance(a, b) ⇒ Object
577
578
579
|
# File 'lib/valkey/objects.rb', line 577
def distance a, b
VK.redis.call("GEODIST", key, a, b, 'm').to_f;
end
|
#radius(lon, lat, r) ⇒ Object
580
581
582
583
584
|
# File 'lib/valkey/objects.rb', line 580
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
556
557
558
559
560
561
562
563
564
565
566
567
568
569
|
# File 'lib/valkey/objects.rb', line 556
def value &b
a = []
VK.redis.call("ZRANGE", key, 0, -1).each_with_index { |e, i|
if block_given?
a << b.call(i, e)
else
a << e
end
};
if @opts.has_key?(:flush) == true
delete!
end
return a
end
|