Class: VORuby::STC::V1_10::Coords::TimeOffsetRef

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

Instance Attribute Summary collapse

Attributes inherited from IdRef

#value

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RelativeTime

#==

Methods included from SerializableToXml

#element

Methods inherited from IdRef

#==

Constructor Details

#initialize(ref, unit = TimeUnit.new('s')) ⇒ TimeOffsetRef

Returns a new instance of TimeOffsetRef.



282
283
284
285
# File 'lib/voruby/stc/1.10/coords.rb', line 282

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

Instance Attribute Details

#unitObject

Returns the value of attribute unit.



280
281
282
# File 'lib/voruby/stc/1.10/coords.rb', line 280

def unit
  @unit
end

Class Method Details

.from_xml(xml) ⇒ Object



306
307
308
309
310
311
312
# File 'lib/voruby/stc/1.10/coords.rb', line 306

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

Instance Method Details

#offsetObject



291
# File 'lib/voruby/stc/1.10/coords.rb', line 291

def offset; self.value end

#offset=(offset) ⇒ Object



292
# File 'lib/voruby/stc/1.10/coords.rb', line 292

def offset=(offset); self.value = offset end

#to_sObject



294
295
296
# File 'lib/voruby/stc/1.10/coords.rb', line 294

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

#to_xmlObject



298
299
300
301
302
303
304
# File 'lib/voruby/stc/1.10/coords.rb', line 298

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