Class: PdfEditor::Merge

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

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

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

#merged_nameObject (readonly)

Returns the value of attribute merged_name.



12
13
14
# File 'lib/pdf_editor/merge.rb', line 12

def merged_name
  @merged_name
end

#resourcesObject (readonly)

Returns the value of attribute resources.



12
13
14
# File 'lib/pdf_editor/merge.rb', line 12

def resources
  @resources
end

Instance Method Details

#callObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/pdf_editor/merge.rb', line 19

def call
  if resources.empty?
    raise Errors::ResourcesEmptyError, 
          'There must be at least one resource to merge'
  end
  PdfEditor::Resource.new(
    create_tempfile {run_command},
    merged_name
  )
end

#post_initObject



14
15
16
17
# File 'lib/pdf_editor/merge.rb', line 14

def post_init
  @resources   = args.fetch(:resources, [])
  @merged_name = args.fetch(:merged_name, nil)
end