Class: TimeNode

Inherits:
XML::Mapping::SingleAttributeNode
  • Object
show all
Defined in:
lib/support/xml_mapping/time_node.rb

Instance Method Summary collapse

Instance Method Details

#extract_attr_value(xml) ⇒ Object

:nodoc:



7
8
9
# File 'lib/support/xml_mapping/time_node.rb', line 7

def extract_attr_value(xml) # :nodoc:
  Time.parse(default_when_xpath_err{ @path.first(xml).text })
end

#initialize_impl(path) ⇒ Object



4
5
6
# File 'lib/support/xml_mapping/time_node.rb', line 4

def initialize_impl(path)
  @path = XML::XXPath.new(path)
end

#set_attr_value(xml, value) ⇒ Object

:nodoc:



10
11
12
13
14
# File 'lib/support/xml_mapping/time_node.rb', line 10

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