Class: EPUBInfo::Parser

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#metadata_documentObject

Returns the value of attribute metadata_document.



3
4
5
# File 'lib/epubinfo/parser.rb', line 3

def 
  @metadata_document
end

#pathObject

Returns the value of attribute path.



3
4
5
# File 'lib/epubinfo/parser.rb', line 3

def path
  @path
end

Class Method Details

.parse(path) ⇒ Object



5
6
7
8
9
# File 'lib/epubinfo/parser.rb', line 5

def self.parse(path)
  epubinfo = EPUBInfo::Parser.new
  epubinfo.path = path
  epubinfo
end

Instance Method Details

#drm_protected?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/epubinfo/parser.rb', line 15

def drm_protected?
  @drm_protected ||= !!zip_file.find_entry('META-INF/rights.xml')
end

#metadata_pathObject



27
28
29
30
31
32
# File 'lib/epubinfo/parser.rb', line 27

def 
  @metadata_path ||= begin
    root_document.remove_namespaces!
    root_document.css('container rootfiles rootfile:first-child').attribute('full-path').content
  end
end

#zip_fileObject



19
20
21
22
23
24
25
# 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