Class: Mindee::V2::Product::Split::SplitResult

Inherits:
Object
  • Object
show all
Defined in:
lib/mindee/v2/product/split/split_result.rb

Overview

Result of a split utility inference.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_response) ⇒ SplitResult

Returns a new instance of SplitResult.

Parameters:

  • server_response (Hash)

    Hash representation of the JSON returned by the service.



15
16
17
18
19
20
21
# File 'lib/mindee/v2/product/split/split_result.rb', line 15

def initialize(server_response)
  @splits = if server_response.key?('splits')
              server_response['splits'].map do |split|
                SplitRange.new(split)
              end
            end
end

Instance Attribute Details

#splitsArray<SplitRange> (readonly)

Returns List of results of splitped document regions.

Returns:

  • (Array<SplitRange>)

    List of results of splitped document regions.



12
13
14
# File 'lib/mindee/v2/product/split/split_result.rb', line 12

def splits
  @splits
end

Instance Method Details

#extract_from_input_source(input_source) ⇒ PDF::ExtractedPDFs

Splits the input PDF.

Parameters:

Returns:



26
27
28
# File 'lib/mindee/v2/product/split/split_result.rb', line 26

def extract_from_input_source(input_source)
  FileOperation::Split.extract_splits(input_source, splits.map(&:page_range))
end

#to_sString

String representation.

Returns:

  • (String)


32
33
34
35
36
# File 'lib/mindee/v2/product/split/split_result.rb', line 32

def to_s
  splits_str = @splits.join("\n")

  "Splits\n======\n#{splits_str}"
end