Class: Thumbnailer::PDF

Inherits:
Base
  • Object
show all
Defined in:
lib/thumbnailer/pdf.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#dir, #height, #image_height, #image_width, #prefix, #sequence, #width

Instance Method Summary collapse

Methods inherited from Base

#output, #write

Constructor Details

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

Returns a new instance of PDF.



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

def initialize(path, options = {})
  super(options)
  @path       = path
  @collection = extract_collection
  @size       = @collection.size
  @format     = options[:format] || 'png'
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



3
4
5
# File 'lib/thumbnailer/pdf.rb', line 3

def collection
  @collection
end

#formatObject (readonly)

Returns the value of attribute format.



3
4
5
# File 'lib/thumbnailer/pdf.rb', line 3

def format
  @format
end

#sizeObject (readonly)

Returns the value of attribute size.



3
4
5
# File 'lib/thumbnailer/pdf.rb', line 3

def size
  @size
end

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/thumbnailer/pdf.rb', line 13

def create
  extract_page
  extract_pages
  sequences = extract_sequences

  @collection.each do |image|
    sequence = sequences.next
    image.format(@format, 1)

    @options[:object]   = image
    @options[:format]   = @format
    @options[:sequence] = sequence

    file = File.new(@path, @options)
    file.create
  end
end