Class: EPUBInfo::Models::Date

Inherits:
Object
  • Object
show all
Defined in:
lib/epubinfo/models/date.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Date

Should never be called directly, go through EPUBInfo.get



17
18
19
20
21
# File 'lib/epubinfo/models/date.rb', line 17

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

Instance Attribute Details

#dateObject

Returns:

  • Date



8
9
10
# File 'lib/epubinfo/models/date.rb', line 8

def date
  @date
end

#date_strObject

Date as a string (EPUB2 reference)

Returns:

  • String



11
12
13
# File 'lib/epubinfo/models/date.rb', line 11

def date_str
  @date_str
end

#eventObject

Event (EPUB2 reference)

Returns:

  • String



14
15
16
# File 'lib/epubinfo/models/date.rb', line 14

def event
  @event
end

Instance Method Details

#to_hashHash

Returns Hash representation of a date

Returns:

  • (Hash)


25
26
27
28
29
30
# File 'lib/epubinfo/models/date.rb', line 25

def to_hash
  {
    :time => @time,
    :event => @event
  }
end