Sha256: a4080bfafa8bc00d382a4b6e3e285ebcd1a81a862031cbc104097d08448efe63

Contents?: true

Size: 757 Bytes

Versions: 4

Compression:

Stored size: 757 Bytes

Contents

require 'time'

module EPUBInfo
  module Models
    class Date
      # Time ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.7 EPUB2 reference})
      # @return [Time]
      attr_accessor :time
      # 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.time = Time.parse(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

4 entries across 4 versions & 1 rubygems

Version Path
epubinfo-0.3.1 lib/epubinfo/models/date.rb
epubinfo-0.3.0 lib/epubinfo/models/date.rb
epubinfo-0.2.4 lib/epubinfo/models/date.rb
epubinfo-0.2.3 lib/epubinfo/models/date.rb