Class: VORuby::VOTables::VOTable::Type::AstroYear
- Defined in:
- lib/voruby/votables/types.rb
Overview
A class representing a valid astronomical year.
Constant Summary collapse
- @@pattern =
'^[JB]?[0-9]+([.][0-9]*)?$'
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(txt = nil) ⇒ AstroYear
constructor
- txt:
-
An astronomical year.
- #to_s ⇒ Object
Constructor Details
#initialize(txt = nil) ⇒ AstroYear
- txt:
-
An astronomical year. The allowed pattern is: [JB]?+([.][0-9]*)?$
i.e. 2001, J2001, B2001, 2001.2 etc.
35 36 37 38 39 40 41 |
# File 'lib/voruby/votables/types.rb', line 35 def initialize(txt=nil) if txt and txt.match(@@pattern) @value = txt else raise "Astro year '#{txt}' does not match #{@@pattern}" end end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
28 29 30 |
# File 'lib/voruby/votables/types.rb', line 28 def value @value end |
Instance Method Details
#to_s ⇒ Object
43 44 45 |
# File 'lib/voruby/votables/types.rb', line 43 def to_s "{#{@value}}" end |