Class: VORuby::VOTables::VOTable::Type::AstroYear

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#valueObject (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_sObject



43
44
45
# File 'lib/voruby/votables/types.rb', line 43

def to_s
"{#{@value}}"
end