class EPUBInfo::Parser
Attributes
metadata_document[RW]
path[RW]
Public Class Methods
parse(path_io)
click to toggle source
# File lib/epubinfo/parser.rb, line 5 def self.parse(path_io) epubinfo = EPUBInfo::Parser.new epubinfo.path = path_io.is_a?(IO) ? path_io.path : path_io 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
metadata_type()
click to toggle source
# File lib/epubinfo/parser.rb, line 34 def metadata_type @metadata_type ||= begin root_document.remove_namespaces! root_document.css('container rootfiles rootfile:first-child').attribute('media-type').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 51 def load_metadata_file Nokogiri::XML(zip_file.read(metadata_path)) end
root_document()
click to toggle source
# File lib/epubinfo/parser.rb, line 43 def root_document begin @root_document ||= Nokogiri::XML(zip_file.read('META-INF/container.xml')) rescue => e raise NotAnEPUBFileError.new(e) end end