class EPUBInfo::Parser
Attributes
metadata_document[RW]
path[RW]
Public Class Methods
parse(path)
click to toggle source
# File lib/epubinfo/parser.rb, line 5 def self.parse(path) epubinfo = EPUBInfo::Parser.new epubinfo.path = path epubinfo end
Public Instance Methods
drm_protected?()
click to toggle source
# File lib/epubinfo/parser.rb, line 15 def drm_protected? @drm_protected ||= !!zip_file.find_entry('META-INF/rights.xml') end
metadata_path()
click to toggle source
# File lib/epubinfo/parser.rb, line 27 def metadata_path @metadata_path ||= begin root_document.remove_namespaces! root_document.css('container rootfiles rootfile:first-child').attribute('full-path').content end end
zip_file()
click to toggle source
# File lib/epubinfo/parser.rb, line 19 def zip_file begin @zip_file ||= Zip::File.open(@path) rescue Zip::Error => e raise NotAnEPUBFileError.new(e) end end
Private Instance Methods
load_metadata_file()
click to toggle source
# File lib/epubinfo/parser.rb, line 44 def load_metadata_file Nokogiri::XML(zip_file.read(metadata_path)) end
root_document()
click to toggle source
# File lib/epubinfo/parser.rb, line 36 def root_document begin @root_document ||= Nokogiri::XML(zip_file.read('META-INF/container.xml')) rescue => e raise NotAnEPUBFileError.new(e) end end