Class: ComicBook::CB

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

Defined Under Namespace

Classes: Archiver, 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



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

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

#extract(_options = {}) ⇒ Object



19
20
21
# File 'lib/comic_book/cb.rb', line 19

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

#infoObject



12
13
14
15
16
17
# File 'lib/comic_book/cb.rb', line 12

def info
  xml_path = File.join path, 'ComicInfo.xml'
  return nil unless File.exist? xml_path

  ComicInfo.load xml_path
end

#pagesObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/comic_book/cb.rb', line 23

def pages
  pattern     = ComicBook::IMAGE_GLOB_PATTERN
  search_path = File.join path, '**', pattern
  image_files = Dir.glob search_path, File::FNM_CASEFOLD

  image_files.sort.map do |file|
    relative_path = Pathname.new(file).relative_path_from(Pathname.new(path)).to_s
    basename      = File.basename file

    ComicBook::Page.new relative_path, basename
  end
end