Class: VORuby::STC::V1_30::TimeOffsetType

Inherits:
Object
  • Object
show all
Includes:
STCReference
Defined in:
lib/voruby/stc/1.30/stc.rb

Overview

Actual elapsed time offset

Direct Known Subclasses

TimeOffset

Instance Attribute Summary collapse

Attributes included from STCReference

#id, #idref, #ucd, #xlink_href, #xlink_type

Class Method Summary collapse

Instance Method Summary collapse

Methods included from STCReference

#stc_reference_eq, stc_reference_from_xml, #stc_reference_to_xml

Methods included from SerializableToXml

#element

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, options={})
  options[:unit] ||= TimeUnitType.new('s')
  
  self.value = value
  options.each { |key, v| send("#{key}=", v) }
end

Instance Attribute Details

#unitObject

Returns the value of attribute unit.



399
400
401
# File 'lib/voruby/stc/1.30/stc.rb', line 399

def unit
  @unit
end

#valueObject

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)
  options = STCReference.stc_reference_from_xml(root)
  
  unit_el = root.attributes.get_attribute_ns(obj_ns.uri, 'unit')
  options[:unit] = TimeUnitType.new(unit_el.value) if unit_el
  
  self.new(value, options)
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