Sha256: 479c133ee6ebf2e16654ee68505d710a29282dc71ab57be13e4e9f9237802f51

Contents?: true

Size: 976 Bytes

Versions: 14

Compression:

Stored size: 976 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 => @time,
          :event => @event
        }
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
epubinfo-0.4.4 lib/epubinfo/models/date.rb
epubinfo_with_toc-0.5.4 lib/epubinfo/models/date.rb
epubinfo_with_toc-0.5.2 lib/epubinfo/models/date.rb
epubinfo_with_toc-0.5.0 lib/epubinfo/models/date.rb
epubinfo_with_toc-0.4.5 lib/epubinfo/models/date.rb
epubinfo-0.4.3 lib/epubinfo/models/date.rb
epubinfo-0.4.2 lib/epubinfo/models/date.rb
epubinfo-0.4.1 lib/epubinfo/models/date.rb
epubinfo-0.4.0 lib/epubinfo/models/date.rb
epubinfo-0.3.6 lib/epubinfo/models/date.rb
epubinfo-0.3.5 lib/epubinfo/models/date.rb
epubinfo-0.3.4 lib/epubinfo/models/date.rb
epubinfo-0.3.3 lib/epubinfo/models/date.rb
epubinfo-0.3.2 lib/epubinfo/models/date.rb