Class: FakeRedis::GeoSet
- Inherits:
-
Object
- Object
- FakeRedis::GeoSet
- Defined in:
- lib/fakeredis/geo_set.rb
Defined Under Namespace
Classes: Point
Instance Method Summary collapse
- #add(lon, lat, name) ⇒ Object
- #get(name) ⇒ Object
-
#initialize ⇒ GeoSet
constructor
A new instance of GeoSet.
- #points_within_radius(center, radius) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize ⇒ GeoSet
Returns a new instance of GeoSet.
62 63 64 |
# File 'lib/fakeredis/geo_set.rb', line 62 def initialize @points = {} end |
Instance Method Details
#add(lon, lat, name) ⇒ Object
70 71 72 |
# File 'lib/fakeredis/geo_set.rb', line 70 def add(lon, lat, name) @points[name] = Point.new(lon, lat, name) end |
#get(name) ⇒ Object
74 75 76 |
# File 'lib/fakeredis/geo_set.rb', line 74 def get(name) @points[name] end |
#points_within_radius(center, radius) ⇒ Object
78 79 80 81 82 |
# File 'lib/fakeredis/geo_set.rb', line 78 def points_within_radius(center, radius) @points.values.select do |point| point.distance_to(center) <= radius end end |
#size ⇒ Object
66 67 68 |
# File 'lib/fakeredis/geo_set.rb', line 66 def size @points.size end |