Class: Speedtest::GeoPoint
- Inherits:
-
Object
- Object
- Speedtest::GeoPoint
- Defined in:
- lib/speedtest/geo_point.rb
Instance Attribute Summary collapse
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#lon ⇒ Object
Returns the value of attribute lon.
Instance Method Summary collapse
- #distance(point) ⇒ Object
-
#initialize(lat, lon) ⇒ GeoPoint
constructor
A new instance of GeoPoint.
- #to_s ⇒ Object
Constructor Details
#initialize(lat, lon) ⇒ GeoPoint
Returns a new instance of GeoPoint.
5 6 7 8 |
# File 'lib/speedtest/geo_point.rb', line 5 def initialize(lat, lon) @lat = Float(lat) @lon = Float(lon) end |
Instance Attribute Details
#lat ⇒ Object
Returns the value of attribute lat.
3 4 5 |
# File 'lib/speedtest/geo_point.rb', line 3 def lat @lat end |
#lon ⇒ Object
Returns the value of attribute lon.
3 4 5 |
# File 'lib/speedtest/geo_point.rb', line 3 def lon @lon end |
Instance Method Details
#distance(point) ⇒ Object
14 15 16 |
# File 'lib/speedtest/geo_point.rb', line 14 def distance(point) Math.sqrt((point.lon - lon)**2 + (point.lat - lat)**2) end |
#to_s ⇒ Object
10 11 12 |
# File 'lib/speedtest/geo_point.rb', line 10 def to_s "[#{lat}, #{lon}]" end |