class EPUBInfo::Models::Book
Attributes
Contributors, array of Person
instances ({idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.6 EPUB2 reference}) @return [Array]
Cover
@return [Cover]
Creators, array of Person
instances ({idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.2 EPUB2 reference}) @return [Array]
Dates, array of Date
instances ({idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.7 EPUB2 reference}) @return [Array]
Description ({idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.4 EPUB2 reference}) @return [String]
DRM protected @return [Boolean]
DRM protected @return [Boolean]
Identifiers, array of Identifier
instances ({idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.10 EPUB2 reference}) @return [Array]
Languages, array of String instances ({idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.12 EPUB2 reference}) @return [Array]
Publisher ({idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.5 EPUB2 reference}) @return [String]
Rights ({idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.15 EPUB2 reference}) @return [String]
Source ({idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.11 EPUB2 reference}) @return [String]
Subjects, array of String instances ({idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.3 EPUB2 reference}) @return [Array]
Titles, array of String instances ({idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.1 EPUB2 reference}) @return [Array]
EPUB Version ({idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section1.4.1.2}) @return [String]
Public Class Methods
Should never be called directly, go through EPUBInfo.get
# File lib/epubinfo/models/book.rb, line 70 def initialize(parser) document = parser.metadata_document return if document.nil? document.remove_namespaces! metadata = document.css('metadata') self.version = document.css('package')[0]['version'] self.titles = metadata.xpath('.//title').map(&:content) self.creators = metadata.xpath('.//creator').map {|c| EPUBInfo::Models::Person.new(c) } self.subjects = metadata.xpath('.//subject').map(&:content) self.description = metadata.xpath('.//description').first.content rescue nil self.publisher = metadata.xpath('.//publisher').first.content rescue nil self.contributors = metadata.xpath('.//contributor').map {|c| EPUBInfo::Models::Person.new(c) } self.dates = metadata.xpath('.//date').map { |d| EPUBInfo::Models::Date.new(d) } modified_date = metadata.xpath(".//meta[@property='dcterms:modified']").map do |d| date = EPUBInfo::Models::Date.new(d) date.event = 'modification' date end self.dates += modified_date; self.identifiers = metadata.xpath('.//identifier').map { |i| EPUBInfo::Models::Identifier.new(i) } self.source = metadata.xpath('.//source').first.content rescue nil self.languages = metadata.xpath('.//language').map(&:content) self.rights = metadata.xpath('.//rights').first.content rescue nil self.drm_protected = parser.drm_protected? self.cover = EPUBInfo::Models::Cover.new(parser) end
Public Instance Methods
Returns Hash representation of the book @return [Hash]
# File lib/epubinfo/models/book.rb, line 100 def to_hash { :titles => @titles, :creators => @creators.map(&:to_hash), :subjects => @subjects, :description => @description, :publisher => @publisher, :contributors => @contributors.map(&:to_hash), :dates => @dates.map(&:to_hash), :identifiers => @identifiers.map(&:to_hash), :source => @source, :languages => @languages, :rights => @rights, :drm_protected => @drm_protected, :cover => @cover, } end