Class: PDFShaver::PageSet

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/pdfshaver/page_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document, page_list = :all, options = {}) ⇒ PageSet

Returns a new instance of PageSet.



6
7
8
9
# File 'lib/pdfshaver/page_set.rb', line 6

def initialize document, page_list=:all, options={}
  @document = document
  @page_list = extract_page_numbers(page_list)
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



5
6
7
# File 'lib/pdfshaver/page_set.rb', line 5

def document
  @document
end

Instance Method Details

#[](page_index) ⇒ Object



15
16
17
# File 'lib/pdfshaver/page_set.rb', line 15

def [](page_index)
  Page.new(@document, @page_list.to_a[page_index])
end

#each(&block) ⇒ Object



11
12
13
# File 'lib/pdfshaver/page_set.rb', line 11

def each(&block)
  enumerator.each(&block)
end

#firstObject



19
20
21
# File 'lib/pdfshaver/page_set.rb', line 19

def first
  Page.new(@document, @page_list.first)
end

#lastObject



23
24
25
# File 'lib/pdfshaver/page_set.rb', line 23

def last
  Page.new(@document, @page_list.last)
end

#sizeObject



27
28
29
# File 'lib/pdfshaver/page_set.rb', line 27

def size
  @page_list.size
end