Sha256: 490434f32a44fa35b96a10562456b52863453d75b9cfb759eba34c9d64ff5a13

Contents?: true

Size: 584 Bytes

Versions: 3

Compression:

Stored size: 584 Bytes

Contents

module Microformats2
  module Property
    class DateTime < Foundation
      def to_s
        @to_s ||= value_class_pattern || element_value || text_value
      end

      def value
        ::DateTime.parse(to_s)
      end

      def to_hash
        if formats.empty?
          to_s
        else
          { value: to_s }.merge(formats.first.to_hash)
        end
      end

      protected

      def attr_map
        @attr_map ||= {
          "time" => "datetime",
          "ins" => "datetime",
          "abbr" => "title",
          "data" => "value" }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
microformats2-2.0.0.pre3 lib/microformats2/property/date_time.rb
microformats2-2.0.0.pre2 lib/microformats2/property/date_time.rb
microformats2-2.0.0.pre1 lib/microformats2/property/date_time.rb