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