Sha256: bc0fac48e6037bdf221eb22a64d7220ae74e706e0d5b8c767eccc625a8ea06fb

Contents?: true

Size: 555 Bytes

Versions: 22

Compression:

Stored size: 555 Bytes

Contents

require_relative 'node_base'

module XML
  module MappingExtensions

    # Maps `Time` objects to ISO 8601 strings.
    class TimeNode < NodeBase

      # param xml_text [String] an ISO 8601 datetime value
      # @return [Time] the value as a UTC `Time`
      def to_value(xml_text)
        Time.iso8601(xml_text).utc
      end

      # @param value [Time] the value as a `Time`
      # @return the value as an ISO 8601 string
      def to_xml_text(value)
        value.utc.iso8601
      end
    end
    ::XML::Mapping.add_node_class TimeNode

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
xml-mapping_extensions-0.4.9 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.4.8 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.4.7 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.4.6 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.4.5 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.4.4 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.4.3 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.4.2 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.4.1 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.4.0 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.3.7 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.3.6 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.3.5 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.3.4 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.3.3 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.3.2 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.3.1 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.3.0 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.2.1 lib/xml/mapping_extensions/time_node.rb
xml-mapping_extensions-0.2.0 lib/xml/mapping_extensions/time_node.rb