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.



16
17
18
19
# File 'lib/mindee/v2/product/split/split_range.rb', line 16

def initialize(server_response)
  @page_range = server_response['page_range']
  @document_type = server_response['document_type']
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

#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:



31
32
33
# File 'lib/mindee/v2/product/split/split_range.rb', line 31

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

#to_sString

String representation.

Returns:

  • (String)


23
24
25
# File 'lib/mindee/v2/product/split/split_range.rb', line 23

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