Class: GpsUnitConversion::MinutesToDecimal::Longitude
- Inherits:
-
Object
- Object
- GpsUnitConversion::MinutesToDecimal::Longitude
- Defined in:
- lib/gps_unit_conversion/minutes_to_decimal/longitude.rb
Instance Attribute Summary collapse
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
-
#longitude ⇒ Object
readonly
Returns the value of attribute longitude.
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(longitude:, direction: 'E') ⇒ Longitude
constructor
A new instance of Longitude.
Constructor Details
#initialize(longitude:, direction: 'E') ⇒ Longitude
6 7 8 9 |
# File 'lib/gps_unit_conversion/minutes_to_decimal/longitude.rb', line 6 def initialize(longitude:, direction: 'E') @longitude = longitude @direction = direction end |
Instance Attribute Details
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
4 5 6 |
# File 'lib/gps_unit_conversion/minutes_to_decimal/longitude.rb', line 4 def direction @direction end |
#longitude ⇒ Object (readonly)
Returns the value of attribute longitude.
4 5 6 |
# File 'lib/gps_unit_conversion/minutes_to_decimal/longitude.rb', line 4 def longitude @longitude end |
Instance Method Details
#convert ⇒ Object
11 12 13 14 |
# File 'lib/gps_unit_conversion/minutes_to_decimal/longitude.rb', line 11 def convert decimal = (degrees + (minutes/60.0) + (seconds/3600.0)).round(DEFAULT_DECIMALS) direction == 'E' ? decimal : -decimal end |