Class: XML::MappingExtensions::TimeNode

Inherits:
NodeBase
  • Object
show all
Defined in:
lib/xml/mapping_extensions/time_node.rb

Overview

Maps Time objects to ISO 8601 strings.

Instance Method Summary collapse

Methods inherited from NodeBase

#extract_attr_value, #initialize, #set_attr_value

Constructor Details

This class inherits a constructor from XML::MappingExtensions::NodeBase

Instance Method Details

#to_value(xml_text) ⇒ Time

param xml_text [String] an ISO 8601 datetime value

Returns:

  • (Time)

    the value as a UTC Time



11
12
13
# File 'lib/xml/mapping_extensions/time_node.rb', line 11

def to_value(xml_text)
  Time.iso8601(xml_text).utc
end

#to_xml_text(value)

Returns the value as an ISO 8601 string.

Parameters:

  • value (Time)

    the value as a Time

Returns:

  • the value as an ISO 8601 string



17
18
19
# File 'lib/xml/mapping_extensions/time_node.rb', line 17

def to_xml_text(value)
  value.utc.iso8601
end