Class: ComicBook::CBZ

Inherits:
Adapter show all
Defined in:
lib/comic_book/cbz.rb,
lib/comic_book/cbz/archiver.rb,
lib/comic_book/cbz/extractor.rb

Defined Under Namespace

Classes: Archiver, Extractor

Instance Method Summary collapse

Methods inherited from Adapter

#images, #images_and_info, #initialize, #pages

Constructor Details

This class inherits a constructor from ComicBook::Adapter

Instance Method Details

#archive(options = {}) ⇒ Object



9
10
11
# File 'lib/comic_book/cbz.rb', line 9

def archive options = {}
  Archiver.new(path).archive options
end

#entriesObject



17
18
19
20
21
22
23
24
25
# File 'lib/comic_book/cbz.rb', line 17

def entries
  names = []

  Zip::File.open(path) do |zipfile|
    zipfile.each { |entry| names << entry.name if entry.file? }
  end

  names.map { ComicBook::Entry.new it }
end

#extract(options = {}) ⇒ Object



13
14
15
# File 'lib/comic_book/cbz.rb', line 13

def extract options = {}
  Extractor.new(path).extract options
end

#infoObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/comic_book/cbz.rb', line 27

def info
  xml = nil

  Zip::File.open(path) do |zipfile|
    entry = zipfile.find_entry('ComicInfo.xml')
    xml   = entry&.get_input_stream&.read
  end

  return nil unless xml

  ComicInfo.load xml
end