Class: VORuby::STC::V1_10::Coords::TimeOffset

Inherits:
Object
  • Object
show all
Includes:
RelativeTime
Defined in:
lib/voruby/stc/1.10/coords.rb

Overview

Actual elapsed time offset

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RelativeTime

#==

Methods included from SerializableToXml

#element

Constructor Details

#initialize(offset, unit = TimeUnit.new('s')) ⇒ TimeOffset

Returns a new instance of TimeOffset.



243
244
245
246
# File 'lib/voruby/stc/1.10/coords.rb', line 243

def initialize(offset, unit=TimeUnit.new('s'))
  self.offset = offset
  self.unit = unit
end

Instance Attribute Details

#offsetObject

Returns the value of attribute offset.



241
242
243
# File 'lib/voruby/stc/1.10/coords.rb', line 241

def offset
  @offset
end

#unitObject

Returns the value of attribute unit.



241
242
243
# File 'lib/voruby/stc/1.10/coords.rb', line 241

def unit
  @unit
end

Class Method Details

.from_xml(xml) ⇒ Object



268
269
270
271
272
273
274
# File 'lib/voruby/stc/1.10/coords.rb', line 268

def self.from_xml(xml)
  node = element_from(xml)
  TimeOffset.new(
    Float(node.text),
    node.attributes.get_attribute_ns(obj_ns.uri, 'unit').value
  )
end

Instance Method Details

#to_sObject



256
257
258
# File 'lib/voruby/stc/1.10/coords.rb', line 256

def to_s
  "#{self.offset} #{self.unit}"
end

#to_xmlObject



260
261
262
263
264
265
266
# File 'lib/voruby/stc/1.10/coords.rb', line 260

def to_xml
  el = element()
  el.text = self.offset.to_s
  el.attributes["#{obj_ns.prefix}:unit"] = self.unit.to_s
  collapse_namespaces(el)
  el
end