Class: VORuby::Simple::Parameters::Declination
- Defined in:
- lib/voruby/simple/parameters.rb
Overview
Represents astronomical latitude.
Class Method Summary collapse
-
.convert_to_decimal_degrees(dec) ⇒ Object
Convert a Dec in d:m:s format to decimal degrees.
Instance Method Summary collapse
- #dec(dec = nil) ⇒ Object
-
#initialize(dec) ⇒ Declination
constructor
A new instance of Declination.
- #to_s ⇒ Object
Constructor Details
#initialize(dec) ⇒ Declination
Returns a new instance of Declination.
71 72 73 |
# File 'lib/voruby/simple/parameters.rb', line 71 def initialize(dec) dec(dec) end |
Class Method Details
.convert_to_decimal_degrees(dec) ⇒ Object
Convert a Dec in d:m:s format to decimal degrees.
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/voruby/simple/parameters.rb', line 92 def self.convert_to_decimal_degrees(dec) degree, arcmin, arcsec = dec.split(':') degree_f = degree.to_f() arcmin_f = (arcmin.to_f() / 60.0) arcsec_f = (arcsec.to_f() / (60.0 * 60.0)) return (degree_f - arcmin_f - arcsec_f) if degree_f < 0 return degree_f + arcmin_f + arcsec_f end |
Instance Method Details
#dec(dec = nil) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/voruby/simple/parameters.rb', line 75 def dec(dec=nil) if dec == nil return @dec else if dec.instance_of?(String) @dec = Declination.convert_to_decimal_degrees(dec) else @dec = dec.to_f() end end end |
#to_s ⇒ Object
87 88 89 |
# File 'lib/voruby/simple/parameters.rb', line 87 def to_s URI.escape(sprintf("DEC=%.3f", @dec)) end |