Class: Mindee::V2::Product::Split::SplitRange

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

Overview

Split inference result.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_response) ⇒ SplitRange

Returns a new instance of SplitRange.

Parameters:

  • server_response (Hash)

    Hash representation of the JSON returned by the service.



17
18
19
20
21
22
23
24
25
# File 'lib/mindee/v2/product/split/split_range.rb', line 17

def initialize(server_response)
  @page_range = server_response['page_range']
  @document_type = server_response['document_type']
  # rubocop:disable Style/GuardClause
  unless server_response['extraction_response'].nil?
    @extraction_response = V2::Product::Extraction::ExtractionResponse.new(server_response['extraction_response'])
  end
  # rubocop:enable Style/GuardClause
end

Instance Attribute Details

#document_typeString (readonly)

Returns The document type, as identified on given classification values.

Returns:

  • (String)

    The document type, as identified on given classification values.



13
14
15
# File 'lib/mindee/v2/product/split/split_range.rb', line 13

def document_type
  @document_type
end

#extraction_responseObject (readonly)

Returns the value of attribute extraction_response.



14
15
16
# File 'lib/mindee/v2/product/split/split_range.rb', line 14

def extraction_response
  @extraction_response
end

#page_rangeArray<Integer> (readonly)

Returns 0-based page indexes, where the first integer indicates the start page and the second integer indicates the end page.

Returns:

  • (Array<Integer>)

    0-based page indexes, where the first integer indicates the start page and the second integer indicates the end page.



11
12
13
# File 'lib/mindee/v2/product/split/split_range.rb', line 11

def page_range
  @page_range
end

Instance Method Details

#extract_from_file(input_source) ⇒ PDF::ExtractedPDF

Apply the split range inference to a file and return a single extracted PDF.

Parameters:

Returns:



37
38
39
# File 'lib/mindee/v2/product/split/split_range.rb', line 37

def extract_from_file(input_source)
  FileOperation::Split.extract_single_split(input_source, @page_range)
end

#to_sString

String representation.

Returns:

  • (String)


29
30
31
# File 'lib/mindee/v2/product/split/split_range.rb', line 29

def to_s
  "* :Page Range: #{@page_range}\n  :Document Type: #{@document_type}"
end