Class: VORuby::Simple::Parameters::RightAscension
- Defined in:
- lib/voruby/simple/parameters.rb
Overview
Represents astronomical longitude.
Class Method Summary collapse
-
.convert_to_decimal_degrees(ra) ⇒ Object
Convert an RA in h:m:s format to decimal degrees.
Instance Method Summary collapse
-
#initialize(ra) ⇒ RightAscension
constructor
A new instance of RightAscension.
- #ra(ra = nil) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(ra) ⇒ RightAscension
Returns a new instance of RightAscension.
32 33 34 |
# File 'lib/voruby/simple/parameters.rb', line 32 def initialize(ra) ra(ra) end |
Class Method Details
.convert_to_decimal_degrees(ra) ⇒ Object
Convert an RA in h:m:s format to decimal degrees.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/voruby/simple/parameters.rb', line 57 def self.convert_to_decimal_degrees(ra) hours, min, sec = ra.split(':') degrees = (hours.to_f() * 15.0) + (min.to_f() * 15.0 / 60.0) + (sec.to_f() * 15.0 / (60.0 * 60.0)) return degrees end |
Instance Method Details
#ra(ra = nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/voruby/simple/parameters.rb', line 36 def ra(ra=nil) if ra == nil return @ra else if ra.instance_of?(String) if ra =~ /[-+]\d+:\d+:\d+(\.\d+)?/ @ra = RightAscension.convert_to_decimal_degrees(ra) else @ra = ra.to_f() end else @ra = ra.to_f() end end end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/voruby/simple/parameters.rb', line 52 def to_s URI.escape(sprintf("RA=%.3f", @ra)) end |