Class: Vivlio::PDF::Source

Inherits:
LocalFile show all
Defined in:
lib/vivlio/pdf/source.rb

Overview

A document to render: a single HTML file, the OPF of an unzipped EPUB, or a webpub manifest. Beyond being a local file, it knows only whether it brings a spine with it.

Constant Summary collapse

OPF_EXTENSIONS =
['.opf'].freeze
MANIFEST_NAMES =
['publication.json', 'manifest.json'].freeze

Instance Attribute Summary

Attributes inherited from LocalFile

#path, #url

Instance Method Summary collapse

Methods inherited from LocalFile

coerce, #to_s

Constructor Details

#initialize(path) ⇒ Source

Returns a new instance of Source.



12
13
14
# File 'lib/vivlio/pdf/source.rb', line 12

def initialize(path)
  super(path, kind: 'source')
end

Instance Method Details

#publication?Boolean

A publication (EPUB/webpub) has a spine to follow; a lone HTML file does not. Only used as the default for Printer#print's book_mode:.

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/vivlio/pdf/source.rb', line 18

def publication?
  OPF_EXTENSIONS.include?(File.extname(path).downcase) ||
    MANIFEST_NAMES.include?(File.basename(path))
end