Class: GpsUnitConversion::MinutesToDecimal::Longitude

Inherits:
Object
  • Object
show all
Defined in:
lib/gps_unit_conversion/minutes_to_decimal/longitude.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#directionObject (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

#longitudeObject (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

#convertObject



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