Class: VORuby::STC::V1_30::ISOTimeType

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

Overview

ISO8601 time; note: only a limited subset of ISO 8601 is allowed: yyyy-mm-ddThh:mm:ss.sss…; unfortunately, XSchema does not allow hh, mm, or ss to be optional, “.ss” is.

Direct Known Subclasses

ISOTime

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 = {}) ⇒ ISOTimeType

Returns a new instance of ISOTimeType.



299
300
301
302
# File 'lib/voruby/stc/1.30/stc.rb', line 299

def initialize(value, options={})
  self.value = value
  options.each { |key, v| send("#{key}=", v) }
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



297
298
299
# File 'lib/voruby/stc/1.30/stc.rb', line 297

def value
  @value
end

Class Method Details

.from_xml(xml) ⇒ Object



323
324
325
326
327
328
329
330
# File 'lib/voruby/stc/1.30/stc.rb', line 323

def self.from_xml(xml)
  root = element_from(xml)
  
  value = DateTime.parse(root.text)
  options = STCReference.stc_reference_from_xml(root)
  
  self.new(value, options)
end

Instance Method Details

#==(t) ⇒ Object



309
310
311
312
# File 'lib/voruby/stc/1.30/stc.rb', line 309

def ==(t)
  self.stc_reference_eq(t) and
  self.value == t.value
end

#to_xml(name = nil) ⇒ Object



314
315
316
317
318
319
320
321
# File 'lib/voruby/stc/1.30/stc.rb', line 314

def to_xml(name=nil)
  el = stc_reference_to_xml(element(name))
  
  el.text = self.value.strftime("%FT%T.%L")
  
  collapse_namespaces(el)
  el
end