class DragonflyPdf::Processors::Rotate
Public Instance Methods
call(content, arg)
click to toggle source
# File lib/dragonfly_pdf/processors/rotate.rb, line 4 def call(content, arg) raise UnsupportedFormat unless content.ext raise UnsupportedFormat unless SUPPORTED_FORMATS.include?(content.ext.downcase) rotate_args = case arg when String, Symbol raise ArgumentError unless arg.to_s =~ /north|south|east|west|left|right|down/i "1-end#{arg}" when Hash pdf_properties = DragonflyPdf::Analysers::PdfProperties.new.call(content) pdf_properties['page_numbers'].map { |page| [page, arg[page]].compact.join }.join(' ') end content.shell_update(ext: 'pdf') do |old_path, new_path| "#{pdftk_command} \"#{old_path}\" cat #{rotate_args} output #{new_path}" end end
Private Instance Methods
pdftk_command()
click to toggle source
# File lib/dragonfly_pdf/processors/rotate.rb, line 24 def pdftk_command 'pdftk' end