Class: Vivlio::PDF::LocalFile
- Inherits:
-
Object
- Object
- Vivlio::PDF::LocalFile
- Defined in:
- lib/vivlio/pdf/local_file.rb
Overview
A file on disk the browser will be pointed at: a path that exists, and the file:// URL naming it.
Everything the viewer loads -- the document, its stylesheets, the
viewer's own index.html -- is one of these. kind only names the thing
in the error raised when it is missing.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path, kind: 'file') ⇒ LocalFile
constructor
A new instance of LocalFile.
- #to_s ⇒ Object
Constructor Details
#initialize(path, kind: 'file') ⇒ LocalFile
Returns a new instance of LocalFile.
20 21 22 23 24 25 26 |
# File 'lib/vivlio/pdf/local_file.rb', line 20 def initialize(path, kind: 'file') @path = File.(path.to_s) raise Error, "#{kind} not found: #{@path}" unless File.exist?(@path) @url = file_url(@path) freeze end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
14 15 16 |
# File 'lib/vivlio/pdf/local_file.rb', line 14 def path @path end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
14 15 16 |
# File 'lib/vivlio/pdf/local_file.rb', line 14 def url @url end |
Class Method Details
.coerce(value) ⇒ Object
16 17 18 |
# File 'lib/vivlio/pdf/local_file.rb', line 16 def self.coerce(value) value.is_a?(self) ? value : new(value) end |
Instance Method Details
#to_s ⇒ Object
28 29 30 |
# File 'lib/vivlio/pdf/local_file.rb', line 28 def to_s path end |