Class: MassInvite::Location
- Inherits:
-
Object
- Object
- MassInvite::Location
- Defined in:
- lib/mass_invite/location.rb
Overview
Location class
Constant Summary collapse
- RAD_PER_DEG =
Math::PI / 180
- EARTH_RADIUS_IN_KM =
6371- LAT_LONG_REGEX =
/^(\+|\-|)(\d+(\.\d+)?)$/
Instance Attribute Summary collapse
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#long ⇒ Object
Returns the value of attribute long.
Instance Method Summary collapse
- #distance_from(location) ⇒ Object
-
#initialize(lat, long) ⇒ Location
constructor
A new instance of Location.
- #lat_in_rad ⇒ Object
- #long_in_rad ⇒ Object
Constructor Details
#initialize(lat, long) ⇒ Location
Returns a new instance of Location.
27 28 29 30 |
# File 'lib/mass_invite/location.rb', line 27 def initialize(lat, long) self.lat = lat self.long = long end |
Instance Attribute Details
#lat ⇒ Object
Returns the value of attribute lat.
25 26 27 |
# File 'lib/mass_invite/location.rb', line 25 def lat @lat end |
#long ⇒ Object
Returns the value of attribute long.
25 26 27 |
# File 'lib/mass_invite/location.rb', line 25 def long @long end |
Instance Method Details
#distance_from(location) ⇒ Object
32 33 34 |
# File 'lib/mass_invite/location.rb', line 32 def distance_from(location) distance(location) end |
#lat_in_rad ⇒ Object
36 37 38 |
# File 'lib/mass_invite/location.rb', line 36 def lat_in_rad @lat * RAD_PER_DEG end |
#long_in_rad ⇒ Object
40 41 42 |
# File 'lib/mass_invite/location.rb', line 40 def long_in_rad @long * RAD_PER_DEG end |