Class: ComicBook::CBR

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

Defined Under Namespace

Classes: Extractor

Instance Method Summary collapse

Methods inherited from Adapter

#initialize

Constructor Details

This class inherits a constructor from ComicBook::Adapter

Instance Method Details

#archive(_options = {}) ⇒ Object

Raises:



8
9
10
# File 'lib/comic_book/cbr.rb', line 8

def archive _options = {}
  raise Error, 'CBR archiving not supported (RAR is proprietary)'
end

#extract(options = {}) ⇒ Object



12
13
14
# File 'lib/comic_book/cbr.rb', line 12

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

#infoObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/comic_book/cbr.rb', line 16

def info
  entries = CLIHelpers.lsar_list path
  return nil unless entries.include? 'ComicInfo.xml'

  Dir.mktmpdir do |temp_dir|
    CLIHelpers.unar_extract path, temp_dir
    xml_path = File.join temp_dir, 'ComicInfo.xml'
    return nil unless File.exist? xml_path

    ComicInfo.load xml_path
  end
end

#pagesObject



29
30
31
32
33
34
# File 'lib/comic_book/cbr.rb', line 29

def pages
  CLIHelpers.lsar_list(path)
            .select { image_file? it }
            .map    { create_page_from_entry it }
            .sort_by(&:name)
end