Class: VORuby::STC::V1_30::TimeOffsetType
- Inherits:
-
Object
- Object
- VORuby::STC::V1_30::TimeOffsetType
- Includes:
- STCReference
- Defined in:
- lib/voruby/stc/1.30/stc.rb
Overview
Actual elapsed time offset
Direct Known Subclasses
Instance Attribute Summary collapse
-
#unit ⇒ Object
Returns the value of attribute unit.
-
#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 = {}) ⇒ TimeOffsetType
constructor
A new instance of TimeOffsetType.
- #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 = {}) ⇒ TimeOffsetType
Returns a new instance of TimeOffsetType.
401 402 403 404 405 406 |
# File 'lib/voruby/stc/1.30/stc.rb', line 401 def initialize(value, ={}) [:unit] ||= TimeUnitType.new('s') self.value = value .each { |key, v| send("#{key}=", v) } end |
Instance Attribute Details
#unit ⇒ Object
Returns the value of attribute unit.
399 400 401 |
# File 'lib/voruby/stc/1.30/stc.rb', line 399 def unit @unit end |
#value ⇒ Object
Returns the value of attribute value.
399 400 401 |
# File 'lib/voruby/stc/1.30/stc.rb', line 399 def value @value end |
Class Method Details
.from_xml(xml) ⇒ Object
438 439 440 441 442 443 444 445 446 447 448 |
# File 'lib/voruby/stc/1.30/stc.rb', line 438 def self.from_xml(xml) root = element_from(xml) value = Float(root.text) = STCReference.stc_reference_from_xml(root) unit_el = root.attributes.get_attribute_ns(obj_ns.uri, 'unit') [:unit] = TimeUnitType.new(unit_el.value) if unit_el self.new(value, ) end |
Instance Method Details
#==(t) ⇒ Object
422 423 424 425 426 |
# File 'lib/voruby/stc/1.30/stc.rb', line 422 def ==(t) self.stc_reference_eq(t) and self.value == t.value and self.unit == t.unit end |
#to_xml(name = nil) ⇒ Object
428 429 430 431 432 433 434 435 436 |
# File 'lib/voruby/stc/1.30/stc.rb', line 428 def to_xml(name=nil) el = stc_reference_to_xml(element(name)) el.text = self.value.to_s el.attributes["#{obj_ns.prefix}:unit"] = self.unit.to_s if self.unit collapse_namespaces(el) el end |