Class: Vivlio::PDF::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/vivlio/pdf/result.rb

Overview

The outcome of one conversion.

Behaves like the output path in string contexts, so callers that only care where the file landed can keep treating the return value as one.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, pages:, bookmarks:, outline: [], warnings: []) ⇒ Result

Returns a new instance of Result.



15
16
17
18
19
20
21
22
# File 'lib/vivlio/pdf/result.rb', line 15

def initialize(path:, pages:, bookmarks:, outline: [], warnings: [])
  @path = path.to_s
  @pages = pages
  @bookmarks = bookmarks
  @outline = outline.freeze
  @warnings = warnings.freeze
  freeze
end

Instance Attribute Details

#bookmarksObject (readonly)

outline is the table of contents we read from the viewer, empty when the bookmarks came from Chromium instead. bookmarks counts what the PDF really contains, so it holds for every outline mode.



13
14
15
# File 'lib/vivlio/pdf/result.rb', line 13

def bookmarks
  @bookmarks
end

#outlineObject (readonly)

outline is the table of contents we read from the viewer, empty when the bookmarks came from Chromium instead. bookmarks counts what the PDF really contains, so it holds for every outline mode.



13
14
15
# File 'lib/vivlio/pdf/result.rb', line 13

def outline
  @outline
end

#pagesObject (readonly)

outline is the table of contents we read from the viewer, empty when the bookmarks came from Chromium instead. bookmarks counts what the PDF really contains, so it holds for every outline mode.



13
14
15
# File 'lib/vivlio/pdf/result.rb', line 13

def pages
  @pages
end

#pathObject (readonly)

outline is the table of contents we read from the viewer, empty when the bookmarks came from Chromium instead. bookmarks counts what the PDF really contains, so it holds for every outline mode.



13
14
15
# File 'lib/vivlio/pdf/result.rb', line 13

def path
  @path
end

#warningsObject (readonly)

outline is the table of contents we read from the viewer, empty when the bookmarks came from Chromium instead. bookmarks counts what the PDF really contains, so it holds for every outline mode.



13
14
15
# File 'lib/vivlio/pdf/result.rb', line 13

def warnings
  @warnings
end

Instance Method Details

#inspectObject



33
34
35
# File 'lib/vivlio/pdf/result.rb', line 33

def inspect
  "#<#{self.class} #{path.inspect} pages=#{pages} bookmarks=#{bookmarks}>"
end

#sizeObject



24
25
26
# File 'lib/vivlio/pdf/result.rb', line 24

def size
  File.size(path)
end

#to_sObject Also known as: to_str



28
29
30
# File 'lib/vivlio/pdf/result.rb', line 28

def to_s
  path
end