Class: PdfEditor::RotatePage

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

Constant Summary collapse

ROTATIONS =
{
  left:   'left',
  right:  'right',
  flip:   'down'
}

Constants included from Errors

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

Constants included from Service

Service::InterfaceNotImplementedError, 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

#pageObject (readonly)

Returns the value of attribute page.



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

def page
  @page
end

#resourceObject (readonly)

Returns the value of attribute resource.



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

def resource
  @resource
end

#rotateObject (readonly)

Returns the value of attribute rotate.



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

def rotate
  @rotate
end

Instance Method Details

#callObject



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

def call
  if resource.nil? || page.nil? || rotate.nil?
    raise Errors::ArgumentMissingError, 
          "resource: #{resource} \n page: #{page} \n rotate: #{rotate}"
  end
  PdfEditor::Resource.new(
    create_tempfile {run_command}
  )
end

#post_initObject



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

def post_init
  @resource   = args.fetch(:resource, nil)
  @page       = args.fetch(:page, nil)
  @rotate     = ROTATIONS[args.fetch(:rotate, '')]
end