Class: DatetimeNode
- Inherits:
-
XML::Mapping::SingleAttributeNode
- Object
- XML::Mapping::SingleAttributeNode
- DatetimeNode
- Defined in:
- lib/support/xml_mapping/datetime_node.rb
Instance Method Summary collapse
-
#extract_attr_value(xml) ⇒ Object
:nodoc:.
-
#initialize(*args) ⇒ DatetimeNode
constructor
A new instance of DatetimeNode.
-
#set_attr_value(xml, value) ⇒ Object
:nodoc:.
Constructor Details
#initialize(*args) ⇒ DatetimeNode
Returns a new instance of DatetimeNode.
5 6 7 8 9 |
# File 'lib/support/xml_mapping/datetime_node.rb', line 5 def initialize(*args) path,*args = super(*args) @path = XML::XXPath.new(path) args end |
Instance Method Details
#extract_attr_value(xml) ⇒ Object
:nodoc:
11 12 13 |
# File 'lib/support/xml_mapping/datetime_node.rb', line 11 def extract_attr_value(xml) # :nodoc: Time.parse(default_when_xpath_err{ @path.first(xml).text }) end |
#set_attr_value(xml, value) ⇒ Object
:nodoc:
15 16 17 18 19 |
# File 'lib/support/xml_mapping/datetime_node.rb', line 15 def set_attr_value(xml, value) # :nodoc: raise "Not a Time object: #{value}" unless value.is_a?(Time) @path.first(xml,:ensure_created=>true).text = value.strftime("%Y-%m-%d %H:%M:%S") end |