Class: GeoPosition::Conversion::Latitude

Inherits:
Object
  • Object
show all
Defined in:
lib/geo_position/conversion/latitude.rb

Constant Summary collapse

BOUNDS =
(-90.0..90.0)

Instance Method Summary collapse

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

#degreesObject



19
20
21
# File 'lib/geo_position/conversion/latitude.rb', line 19

def degrees
  @degrees
end

#directionObject



31
32
33
# File 'lib/geo_position/conversion/latitude.rb', line 31

def direction
  determine_direction
end

#minutesObject



23
24
25
# File 'lib/geo_position/conversion/latitude.rb', line 23

def minutes
  @minutes
end

#secondsObject



27
28
29
# File 'lib/geo_position/conversion/latitude.rb', line 27

def seconds
  @seconds
end

#to_sObject



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