lib/access/geolocation.rb in access-2.0.23 vs lib/access/geolocation.rb in access-2.0.24
- old
+ new
@@ -1,11 +1,28 @@
module Access
class Geolocation
attr_accessor :lat, :lon
- def initialize(geolocation = {})
- @lat = geolocation['lat']
- @lon = geolocation['lon']
+ def self.search(options = {})
+ Access::Api.new.geolocation_search options
+ end
+
+ def self.find(options = {})
+ Access::Api.new.geolocation_find options
+ end
+
+ def self.process_batch(chunk)
+ chunk.map { |location| new(location) }
+ end
+
+ def initialize(values)
+ self.class.class_eval {attr_reader *values.keys }
+ values.each do |attribute_name, attribute_value|
+ self.instance_variable_set("@#{attribute_name}", attribute_value)
+ end
+
+ @lat = @geolocation['lat']
+ @lon = @geolocation['lon']
end
end
end