Class: XML::MappingExtensions::DateNode
- Inherits:
-
NodeBase
- Object
- XML::Mapping::SingleAttributeNode
- NodeBase
- XML::MappingExtensions::DateNode
- Defined in:
- lib/xml/mapping_extensions/date_node.rb
Overview
XML mapping for XML Schema dates. Known limitation: loses time zone info
Instance Method Summary collapse
-
#initialize(*args) ⇒ DateNode
constructor
A new instance of DateNode.
-
#to_value(xml_text) ⇒ Date
param xml_text [String] an XML Schema date.
-
#to_xml_text(value) ⇒ String
The value as an XML Schema date string, without time zone information.
-
#zulu ⇒ Boolean?
Whether date should be output with UTC "Zulu" time designator ("Z").
Methods inherited from NodeBase
#extract_attr_value, #set_attr_value
Constructor Details
#initialize(*args) ⇒ DateNode
Returns a new instance of DateNode.
11 12 13 |
# File 'lib/xml/mapping_extensions/date_node.rb', line 11 def initialize(*args) super end |
Instance Method Details
#to_value(xml_text) ⇒ Date
param xml_text [String] an XML Schema date
25 26 27 |
# File 'lib/xml/mapping_extensions/date_node.rb', line 25 def to_value(xml_text) Date.xmlschema(xml_text) end |
#to_xml_text(value) ⇒ String
Returns the value as an XML Schema date string, without time zone information.
32 33 34 35 |
# File 'lib/xml/mapping_extensions/date_node.rb', line 32 def to_xml_text(value) text = value.xmlschema zulu ? "#{text}Z" : text end |
#zulu ⇒ Boolean?
Whether date should be output with UTC "Zulu" time designator ("Z")
19 20 21 |
# File 'lib/xml/mapping_extensions/date_node.rb', line 19 def zulu @options[:zulu] end |