Class: PdfEditor::Shuffle

Inherits:
Object
  • Object
show all
Includes:
Errors, PdfRunner, Service
Defined in:
lib/pdf_editor/shuffle.rb

Direct Known Subclasses

RemovePages, Reorder

Constant Summary

Constants included from Errors

Errors::ArgumentMissingError, Errors::InvalidInputError, Errors::InvalidPDFError, Errors::PageCountError, Errors::PageOrderInvalidError, Errors::PageRangeError, Errors::ResourcesEmptyError, Errors::TitlePageTitleError

Constants included from Service

PdfEditor::Service::InterfaceNotImplementedError, PdfEditor::Service::MustPassBlockToAsTempfile

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PdfRunner

#pdf_runner

Methods included from Service

included, #initialize

Instance Attribute Details

#page_orderObject (readonly)

Page order does not require unique members and is not sorted. This is the base class for other shuffle operations.



18
19
20
# File 'lib/pdf_editor/shuffle.rb', line 18

def page_order
  @page_order
end

#resourceObject (readonly)

Page order does not require unique members and is not sorted. This is the base class for other shuffle operations.



18
19
20
# File 'lib/pdf_editor/shuffle.rb', line 18

def resource
  @resource
end

Instance Method Details

#callObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pdf_editor/shuffle.rb', line 25

def call
  if resource.nil?
    raise Errors::ResourcesEmptyError, 'Must have a resource to shuffle'
  end
  if page_order.empty?
    raise Errors::PageOrderInvalidError, 'Page order was invalid'
  end
  PdfEditor::Resource.new(
    create_tempfile {run_command}
  )
end

#post_initObject



20
21
22
23
# File 'lib/pdf_editor/shuffle.rb', line 20

def post_init
  @resource   = args[:resource]
  @page_order = args.fetch(:page_order, [])
end