class EPUBMeta::Parser
Attributes
metadata_document[RW]
path[RW]
Public Class Methods
parse(path)
click to toggle source
# File lib/epubmeta/parser.rb, line 5 def self.parse(path) epubmeta = EPUBMeta::Parser.new epubmeta.path = path epubmeta end
Public Instance Methods
drm_protected?()
click to toggle source
# File lib/epubmeta/parser.rb, line 15 def drm_protected? @drm_protected ||= !!zip_file.find_entry('META-INF/rights.xml') end
get_full_path(container_root_doc)
click to toggle source
# File lib/epubmeta/parser.rb, line 31 def get_full_path(container_root_doc) container_root_doc.remove_namespaces! container_root_doc.css('container rootfiles rootfile:first-child').attribute('full-path').content end
metadata_path()
click to toggle source
# File lib/epubmeta/parser.rb, line 27 def metadata_path @metadata_path ||= get_full_path(root_document) end
zip_file()
click to toggle source
# File lib/epubmeta/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/epubmeta/parser.rb, line 46 def load_metadata_file Nokogiri::XML(zip_file.read(metadata_path)) end
root_document()
click to toggle source
# File lib/epubmeta/parser.rb, line 38 def root_document begin @root_document ||= Nokogiri::XML(zip_file.read('META-INF/container.xml')) rescue => e raise NotAnEPUBFileError.new(e) end end