Class: VORuby::STC::V1_30::JDTimeType
- Inherits:
-
Object
- Object
- VORuby::STC::V1_30::JDTimeType
- Includes:
- STCReference
- Defined in:
- lib/voruby/stc/1.30/stc.rb
Overview
A decimal type for JD and MJD, with optional referencing.
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Attributes included from STCReference
#id, #idref, #ucd, #xlink_href, #xlink_type
Class Method Summary collapse
Instance Method Summary collapse
- #==(t) ⇒ Object
-
#initialize(value, options = {}) ⇒ JDTimeType
constructor
A new instance of JDTimeType.
- #to_datetime ⇒ Object
- #to_xml(name = nil) ⇒ Object
Methods included from STCReference
#stc_reference_eq, stc_reference_from_xml, #stc_reference_to_xml
Methods included from SerializableToXml
Constructor Details
#initialize(value, options = {}) ⇒ JDTimeType
Returns a new instance of JDTimeType.
339 340 341 342 |
# File 'lib/voruby/stc/1.30/stc.rb', line 339 def initialize(value, ={}) self.value = value .each { |key, v| send("#{key}=", v) } end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
337 338 339 |
# File 'lib/voruby/stc/1.30/stc.rb', line 337 def value @value end |
Class Method Details
.from_xml(xml) ⇒ Object
367 368 369 370 371 372 373 374 |
# File 'lib/voruby/stc/1.30/stc.rb', line 367 def self.from_xml(xml) root = element_from(xml) value = Float(root.text) = STCReference.stc_reference_from_xml(root) self.new(value, ) end |
Instance Method Details
#==(t) ⇒ Object
349 350 351 352 |
# File 'lib/voruby/stc/1.30/stc.rb', line 349 def ==(t) self.stc_reference_eq(t) and self.value == t.value end |
#to_datetime ⇒ Object
354 355 356 |
# File 'lib/voruby/stc/1.30/stc.rb', line 354 def to_datetime DateTime.jd(self.value) end |
#to_xml(name = nil) ⇒ Object
358 359 360 361 362 363 364 365 |
# File 'lib/voruby/stc/1.30/stc.rb', line 358 def to_xml(name=nil) el = stc_reference_to_xml(element(name)) el.text = self.value.to_s collapse_namespaces(el) el end |