Class: PDFShaver::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/pdfshaver/document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ Document

Returns a new instance of Document.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
# File 'lib/pdfshaver/document.rb', line 5

def initialize path, options={}
  raise ArgumentError, "Can't find a file at '#{path}' to open" unless File.exists? path
  # otherwise attempt to acquire it.
  
  @path = path
  open_document_with_pdfium(path)
end

Instance Attribute Details

#lengthObject (readonly)

Returns the value of attribute length.



3
4
5
# File 'lib/pdfshaver/document.rb', line 3

def length
  @length
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/pdfshaver/document.rb', line 3

def path
  @path
end

Instance Method Details

#==(other) ⇒ Object



13
14
15
# File 'lib/pdfshaver/document.rb', line 13

def == other
  File.realpath(self.path) == File.realpath(other.path)
end

#pages(page_list = :all) ⇒ Object



17
18
19
# File 'lib/pdfshaver/document.rb', line 17

def pages(page_list=:all)
  PageSet.new(self, page_list)
end