Class: ComicBook
- Inherits:
-
Object
show all
- Defined in:
- lib/comic_book/adapter.rb,
lib/comicbook.rb,
lib/comic_book/cb.rb,
lib/comic_book/cb7.rb,
lib/comic_book/cba.rb,
lib/comic_book/cbr.rb,
lib/comic_book/cbt.rb,
lib/comic_book/cbz.rb,
lib/comic_book/cli.rb,
lib/comic_book/pdf.rb,
lib/comic_book/page.rb,
lib/comic_book/version.rb,
lib/comic_book/cb/archiver.rb,
lib/comic_book/cli_helpers.rb,
lib/comic_book/cb/extractor.rb,
lib/comic_book/cb7/archiver.rb,
lib/comic_book/cbt/archiver.rb,
lib/comic_book/cbz/archiver.rb,
lib/comic_book/cb7/extractor.rb,
lib/comic_book/cbr/extractor.rb,
lib/comic_book/cbt/extractor.rb,
lib/comic_book/cbz/extractor.rb,
lib/comic_book/pdf/extractor.rb
Overview
NOTE: don’t use ComicBook::Adapter.new directly
Inherit from it when making an adapter to formats:
.cb7 .cba .cbr .cbt .cbz
Defined Under Namespace
Classes: Adapter, CB, CB7, CBA, CBR, CBT, CBZ, CLI, CLIHelpers, Error, PDF, Page
Constant Summary
collapse
- Info =
ComicInfo::Issue
- IMAGE_EXTENSIONS =
%w[.jpg .jpeg .png .gif .bmp .webp].freeze
- IMAGE_GLOB_PATTERN =
'*.{jpg,jpeg,png,gif,bmp,webp}'.freeze
- VERSION =
'0.3.0'.freeze
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(path) ⇒ ComicBook
Returns a new instance of ComicBook.
22
23
24
25
26
|
# File 'lib/comicbook.rb', line 22
def initialize path
@path = File.expand_path path.strip
@type = determine_type path
validate_path!
end
|
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
20
21
22
|
# File 'lib/comicbook.rb', line 20
def path
@path
end
|
#type ⇒ Object
Returns the value of attribute type.
20
21
22
|
# File 'lib/comicbook.rb', line 20
def type
@type
end
|
Class Method Details
.archive(path, options = {}) ⇒ Object
32
33
34
|
# File 'lib/comicbook.rb', line 32
def self.archive path, options = {}
new(path).archive options
end
|
36
37
38
|
# File 'lib/comicbook.rb', line 36
def self. path, options = {}
new(path). options
end
|
.load(path) ⇒ Object
28
29
30
|
# File 'lib/comicbook.rb', line 28
def self.load path
new path
end
|
Instance Method Details
#archive(options = {}) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/comicbook.rb', line 53
def archive options = {}
raise Error, 'Cannot archive a file' unless %i[folder cb].include?(type)
output_format = options[:to] ? File.extname(options[:to]).downcase : '.cbz'
case output_format
when '.cb' then CB.new(path).archive options
when '.cb7' then CB7.new(path).archive options
when '.cbt' then CBT.new(path).archive options
when '.cbz' then CBZ.new(path).archive options
else
raise Error, "Unsupported archive format: #{output_format}"
end
end
|
68
69
70
71
72
73
|
# File 'lib/comicbook.rb', line 68
def options = {}
raise Error, 'Cannot extract a folder' if type == :folder
raise Error, '.cb folders are already extracted (they are uncompressed folders)' if type == :cb
adapter. options
end
|
#info ⇒ Object
47
48
49
50
51
|
# File 'lib/comicbook.rb', line 47
def info
return CB.new(path).info if type == :folder
adapter.info
end
|
#pages ⇒ Object
40
41
42
43
44
45
|
# File 'lib/comicbook.rb', line 40
def pages
case type
when :folder then folder_pages
else adapter.pages
end
end
|