Class: VORuby::STC::V1_10::Coords::AstronTime
- Inherits:
-
Object
- Object
- VORuby::STC::V1_10::Coords::AstronTime
- Includes:
- SerializableToXml
- Defined in:
- lib/voruby/stc/1.10/coords.rb
Overview
AstronTime is the generalized astronomical time type and consists of two or three elements: TimeScale, optional relative time offset, and an absolute time (ISO8601 or a decimal JD or MJD; or it may be an IDREF to one of those three)
Instance Attribute Summary collapse
-
#absolute_time ⇒ Object
Returns the value of attribute absolute_time.
-
#relative_time ⇒ Object
Returns the value of attribute relative_time.
-
#timescale ⇒ Object
Returns the value of attribute timescale.
Class Method Summary collapse
Instance Method Summary collapse
- #==(time) ⇒ Object
-
#initialize(timescale, absolute_time, relative_time = nil) ⇒ AstronTime
constructor
A new instance of AstronTime.
- #to_xml(name = nil, ns = nil) ⇒ Object
Methods included from SerializableToXml
Constructor Details
#initialize(timescale, absolute_time, relative_time = nil) ⇒ AstronTime
Returns a new instance of AstronTime.
323 324 325 326 327 |
# File 'lib/voruby/stc/1.10/coords.rb', line 323 def initialize(timescale, absolute_time, relative_time=nil) self.timescale = timescale self.absolute_time = absolute_time self.relative_time = relative_time end |
Instance Attribute Details
#absolute_time ⇒ Object
Returns the value of attribute absolute_time.
321 322 323 |
# File 'lib/voruby/stc/1.10/coords.rb', line 321 def absolute_time @absolute_time end |
#relative_time ⇒ Object
Returns the value of attribute relative_time.
321 322 323 |
# File 'lib/voruby/stc/1.10/coords.rb', line 321 def relative_time @relative_time end |
#timescale ⇒ Object
Returns the value of attribute timescale.
321 322 323 |
# File 'lib/voruby/stc/1.10/coords.rb', line 321 def timescale @timescale end |
Class Method Details
.from_xml(xml) ⇒ Object
359 360 361 362 363 364 365 366 367 368 369 |
# File 'lib/voruby/stc/1.10/coords.rb', line 359 def self.from_xml(xml) root = element_from(xml) = { :timescale => TimeScale.new(REXML::XPath.first(root, 'x:Timescale', {'x' => obj_ns.uri}).text), :absolute_time => xml_to_obj(root, AbsoluteTime, true) } [:relative_time] = xml_to_obj(root, RelativeTime, true) AstronTime.new([:timescale], [:absolute_time], [:relative_time]) end |
Instance Method Details
#==(time) ⇒ Object
371 372 373 374 375 |
# File 'lib/voruby/stc/1.10/coords.rb', line 371 def ==(time) self.timescale == time.timescale and self.absolute_time == time.absolute_time and self.relative_time == time.relative_time end |
#to_xml(name = nil, ns = nil) ⇒ Object
344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/voruby/stc/1.10/coords.rb', line 344 def to_xml(name=nil, ns=nil) el = element(name, ns) timescale = REXML::Element.new("#{obj_ns.prefix}:Timescale") timescale.text = self.timescale.to_s el.add_element(timescale) el.add_element(self.relative_time.to_xml) if self.relative_time el.add_element(self.absolute_time.to_xml) collapse_namespaces(el) el end |