Class: Pdf4me::SplitByPageNr

Inherits:
WrapperAction show all
Defined in:
lib/pdf4me/actions/split_by_page_nr.rb

Instance Attribute Summary collapse

Attributes inherited from WrapperAction

#client

Instance Method Summary collapse

Methods inherited from WrapperAction

#assign_attributes, #defaults, #initialize, #run!

Constructor Details

This class inherits a constructor from Pdf4me::WrapperAction

Instance Attribute Details

#fileObject

Returns the value of attribute file.



3
4
5
# File 'lib/pdf4me/actions/split_by_page_nr.rb', line 3

def file
  @file
end

#first_pdfObject

Returns the value of attribute first_pdf.



3
4
5
# File 'lib/pdf4me/actions/split_by_page_nr.rb', line 3

def first_pdf
  @first_pdf
end

#page_numberObject

Returns the value of attribute page_number.



3
4
5
# File 'lib/pdf4me/actions/split_by_page_nr.rb', line 3

def page_number
  @page_number
end

#second_pdfObject

Returns the value of attribute second_pdf.



3
4
5
# File 'lib/pdf4me/actions/split_by_page_nr.rb', line 3

def second_pdf
  @second_pdf
end

Instance Method Details

#call_apiObject



25
26
27
28
29
30
31
# File 'lib/pdf4me/actions/split_by_page_nr.rb', line 25

def call_api
  client.multipart_post(
    path,
    file: File.open(file, 'rb'),
    pageNr: page_number
  )
end

#pathObject



13
14
15
# File 'lib/pdf4me/actions/split_by_page_nr.rb', line 13

def path
  '/Split/SplitByPageNr'
end

#runObject



33
34
35
36
37
38
39
# File 'lib/pdf4me/actions/split_by_page_nr.rb', line 33

def run
  validate!
  response = call_api
  response.success?.tap do |result|
    result && save_encoded_files(response)
  end
end