Class: Mindee::V2::FileOperation::SplitFiles

Inherits:
Array
  • Object
show all
Defined in:
lib/mindee/v2/file_operation/split_files.rb

Overview

Collection of split files.

Instance Method Summary collapse

Instance Method Details

#save_all_to_disk(path, prefix: 'split') ⇒ Object

Save all extracted splits to disk.

Parameters:

  • path (String, Pathname)

    Path to save the extracted splits to.

  • prefix (String) (defaults to: 'split')

    Prefix to add to the filename, defaults to ‘split’.



12
13
14
15
16
17
18
19
20
21
# File 'lib/mindee/v2/file_operation/split_files.rb', line 12

def save_all_to_disk(path, prefix: 'split')
  FileUtils.mkdir_p(path)

  each.with_index(1) do |split, idx|
    filename = "#{prefix}_#{format('%03d', idx)}.pdf"
    file_path = File.join(path.to_s, filename)

    split.write_to_file(file_path)
  end
end