Sha256: 9b5b86772e0dacd0fd57a527bc0e966da5c4591d5b6c60fe175370ff9f901314

Contents?: true

Size: 980 Bytes

Versions: 3

Compression:

Stored size: 980 Bytes

Contents

require 'time'

module EPUBInfo
  module Models
    class Date
      # Date ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.7 EPUB2 reference})
      # @return Date
      attr_accessor :date
      # Date as a string ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.7 EPUB2 reference})
      # @return String
      attr_accessor :date_str
      # Event ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.7 EPUB2 reference})
      # @return String
      attr_accessor :event

      # Should never be called directly, go through EPUBInfo.get
      def initialize(node)
        self.date = Utils.parse_iso_8601_date(node.content) rescue nil
        self.date_str = node.content
        self.event = node.attribute('event').content rescue nil
      end

      # Returns Hash representation of a date
      # @return [Hash]
      def to_hash
        {
          :time => @date_str,
          :event => @event
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
epubinfo_with_toc-0.5.7 lib/epubinfo/models/date.rb
epubinfo_with_toc-0.5.6 lib/epubinfo/models/date.rb
epubinfo_with_toc-0.5.5 lib/epubinfo/models/date.rb