Class: Longitude
Overview
Subclass of Angle to add in special treatment of to_d, to_r and to_s Longitude degrees are between -2PI and 2PI, West to East (+/- 180 degrees)
Instance Attribute Summary
Attributes inherited from Angle
Instance Method Summary collapse
-
#to_degrees ⇒ Float
(also: #to_deg)
Angle as degrees in range -180 and 180.
-
#to_radians ⇒ Float
(also: #to_r, #to_rad)
Angle as degrees in range -2PI and 2PI.
-
#to_s(fmt = "%3d %2m'%2.4s\"%E") ⇒ String
A West angle is negative, East is Positive.
Methods inherited from Angle
#%, #*, #**, #+, #+@, #-, #-@, #/, #<=>, #abs, #coerce, decimal_deg, decimal_deg_from_ary, degrees, dms, #initialize, radians, #reverse, #sign, #strf, #to_bearing, #to_dms, #to_i
Constructor Details
This class inherits a constructor from Angle
Instance Method Details
#to_degrees ⇒ Float Also known as: to_deg
Returns angle as degrees in range -180 and 180.
7 8 9 10 11 12 13 |
# File 'lib/longitude.rb', line 7 def to_degrees degrees = super if degrees > 180 then degrees - 360 else degrees end end |
#to_radians ⇒ Float Also known as: to_r, to_rad
Returns angle as degrees in range -2PI and 2PI.
16 17 18 19 20 21 |
# File 'lib/longitude.rb', line 16 def to_radians if @angle > Math::PI then @angle - 2 * Math::PI else @angle end end |
#to_s(fmt = "%3d %2m'%2.4s\"%E") ⇒ String
A West angle is negative, East is Positive.
26 27 28 |
# File 'lib/longitude.rb', line 26 def to_s(fmt = "%3d %2m'%2.4s\"%E") super(fmt) end |