class Thumbnailer::PDF
Attributes
collection[R]
format[R]
size[R]
Public Class Methods
new(path, options = {})
click to toggle source
Calls superclass method
Thumbnailer::Base::new
# 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
Public Instance Methods
create()
click to toggle source
# 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
Private Instance Methods
extract_collection()
click to toggle source
# File lib/thumbnailer/pdf.rb, line 49 def extract_collection ::MiniMagick::Image.open(@path).pages end
extract_page()
click to toggle source
# File lib/thumbnailer/pdf.rb, line 39 def extract_page return if !@options[:page] @collection = [ @collection[@options[:page] - 1] ] end
extract_pages()
click to toggle source
# File lib/thumbnailer/pdf.rb, line 44 def extract_pages return if !@options[:pages] @collection = @options[:pages].map { |page| @collection[page - 1] } end
extract_sequences()
click to toggle source
# File lib/thumbnailer/pdf.rb, line 33 def extract_sequences return (1..@collection.size).to_a.each if !@options[:page] && !@options[:pages] return [ @options[:page] ].each if @options[:page] return @options[:pages].each if @options[:pages] end