Class: NearestTimeZone::City
- Inherits:
-
Object
- Object
- NearestTimeZone::City
- Defined in:
- lib/nearest_time_zone/city.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#latitude ⇒ Object
Returns the value of attribute latitude.
-
#longitude ⇒ Object
Returns the value of attribute longitude.
-
#time_zone_id ⇒ Object
Returns the value of attribute time_zone_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id, latitude, longitude, time_zone_id) ⇒ City
constructor
A new instance of City.
- #time_zone ⇒ Object
Constructor Details
#initialize(id, latitude, longitude, time_zone_id) ⇒ City
Returns a new instance of City.
6 7 8 |
# File 'lib/nearest_time_zone/city.rb', line 6 def initialize(id, latitude, longitude, time_zone_id) self.id, self.latitude, self.longitude, self.time_zone_id = id, latitude, longitude, time_zone_id end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/nearest_time_zone/city.rb', line 4 def id @id end |
#latitude ⇒ Object
Returns the value of attribute latitude.
4 5 6 |
# File 'lib/nearest_time_zone/city.rb', line 4 def latitude @latitude end |
#longitude ⇒ Object
Returns the value of attribute longitude.
4 5 6 |
# File 'lib/nearest_time_zone/city.rb', line 4 def longitude @longitude end |
#time_zone_id ⇒ Object
Returns the value of attribute time_zone_id.
4 5 6 |
# File 'lib/nearest_time_zone/city.rb', line 4 def time_zone_id @time_zone_id end |
Class Method Details
.all ⇒ Object
26 27 28 |
# File 'lib/nearest_time_zone/city.rb', line 26 def self.all @all ||= load_all end |
.find(id) ⇒ Object
30 31 32 |
# File 'lib/nearest_time_zone/city.rb', line 30 def self.find(id) all[id.to_i] end |
.kdtree ⇒ Object
10 11 12 |
# File 'lib/nearest_time_zone/city.rb', line 10 def self.kdtree @kdtree ||= build_kdtree end |
.nearest(latitude, longitude) ⇒ Object
34 35 36 |
# File 'lib/nearest_time_zone/city.rb', line 34 def self.nearest(latitude, longitude) all[kdtree.nearest(latitude, longitude)] end |