class PdfEditor::RemovePages
Public Instance Methods
post_init()
click to toggle source
Page order has a unique set of members and is sorted. This allows pdftk to not burst the document into single pages where possible.
Calls superclass method
# File lib/pdf_editor/remove_pages.rb, line 12 def post_init super @page_order = @page_order.uniq.sort end
Private Instance Methods
find_consecutives()
click to toggle source
# File lib/pdf_editor/remove_pages.rb, line 30 def find_consecutives enum = page_order.to_enum result, consecutives = [], [] loop do consecutives << enum.next unless enum.peek == consecutives.last.succ result << consecutives consecutives = [] end end result << consecutives unless consecutives.empty? result end
format_command()
click to toggle source
# File lib/pdf_editor/remove_pages.rb, line 19 def format_command consecutive_pages = find_consecutives consecutive_pages.map do |sub_arr| { :pdf => resource.path, :start => sub_arr.first, :end => sub_arr.last } end end