Class: Resync::XML::TimeNode
- Inherits:
-
XML::Mapping::SingleAttributeNode
- Object
- XML::Mapping::SingleAttributeNode
- Resync::XML::TimeNode
- Defined in:
- lib/resync/xml.rb
Overview
Maps Time objects.
Instance Method Summary collapse
-
#extract_attr_value(xml) ⇒ Object
Implements ::XML::Mapping::SingleAttributeNode#extract_attr_value.
-
#initialize(*args) ⇒ TimeNode
constructor
A new instance of TimeNode.
-
#set_attr_value(xml, value) ⇒ Object
Implements ::XML::Mapping::SingleAttributeNode#set_attr_value.
Constructor Details
#initialize(*args) ⇒ TimeNode
Returns a new instance of TimeNode.
63 64 65 66 67 |
# File 'lib/resync/xml.rb', line 63 def initialize(*args) path, *args = super(*args) @path = ::XML::XXPath.new(path) args end |
Instance Method Details
#extract_attr_value(xml) ⇒ Object
Implements ::XML::Mapping::SingleAttributeNode#extract_attr_value.
70 71 72 73 |
# File 'lib/resync/xml.rb', line 70 def extract_attr_value(xml) value = default_when_xpath_err { @path.first(xml).text } value ? Time.iso8601(value).utc : nil end |
#set_attr_value(xml, value) ⇒ Object
Implements ::XML::Mapping::SingleAttributeNode#set_attr_value.
76 77 78 |
# File 'lib/resync/xml.rb', line 76 def set_attr_value(xml, value) @path.first(xml, ensure_created: true).text = value.iso8601 end |