Class: GeoPosition::Conversion::Latitude
- Inherits:
-
Object
- Object
- GeoPosition::Conversion::Latitude
- Defined in:
- lib/geo_position/conversion/latitude.rb
Constant Summary collapse
- BOUNDS =
(-90.0..90.0)
Instance Method Summary collapse
- #degrees ⇒ Object
- #direction ⇒ Object
-
#initialize(latitude) ⇒ Latitude
constructor
A new instance of Latitude.
- #minutes ⇒ Object
- #seconds ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(latitude) ⇒ Latitude
Returns a new instance of Latitude.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/geo_position/conversion/latitude.rb', line 6 def initialize(latitude) raise GeoPosition::Error::InvalidFloatError.new("Arguments could not be coerced to a float") unless valid_float?(latitude) raise GeoPosition::Error::InvalidLatitudeError.new("Latitde must be between -90 and 90 degrees: %s provided" % [latitude]) unless within_bounds?(latitude) @latitude = latitude.to_f @degrees = 0 @minutes = 0 @seconds = 0 convert! end |
Instance Method Details
#degrees ⇒ Object
19 20 21 |
# File 'lib/geo_position/conversion/latitude.rb', line 19 def degrees @degrees end |
#direction ⇒ Object
31 32 33 |
# File 'lib/geo_position/conversion/latitude.rb', line 31 def direction determine_direction end |
#minutes ⇒ Object
23 24 25 |
# File 'lib/geo_position/conversion/latitude.rb', line 23 def minutes @minutes end |
#seconds ⇒ Object
27 28 29 |
# File 'lib/geo_position/conversion/latitude.rb', line 27 def seconds @seconds end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/geo_position/conversion/latitude.rb', line 35 def to_s "%s deg %s' %s\" %s" % [self.degrees, self.minutes, self.seconds, self.direction] end |