Class: Mindee::V2::Parsing::BaseInference

Inherits:
Mindee::V2::Product::BaseProduct show all
Defined in:
lib/mindee/v2/parsing/base_inference.rb

Overview

Base class for V2 inference responses.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_response) ⇒ BaseInference

Returns a new instance of BaseInference.

Raises:

  • (ArgumentError)


20
21
22
23
24
25
26
27
28
# File 'lib/mindee/v2/parsing/base_inference.rb', line 20

def initialize(http_response)
  raise ArgumentError, 'Server response must be a Hash' unless http_response.is_a?(Hash)

  super()
  @model = Mindee::Parsing::V2::InferenceModel.new(http_response['model'])
  @file = Mindee::Parsing::V2::InferenceFile.new(http_response['file'])
  @id = http_response['id']
  @job = Mindee::Parsing::V2::InferenceJob.new(http_response['job']) if http_response.key?('job')
end

Instance Attribute Details

#fileParsing::V2::InferenceFile (readonly)

Returns File info for the inference.

Returns:



16
17
18
# File 'lib/mindee/v2/parsing/base_inference.rb', line 16

def file
  @file
end

#idString (readonly)

Returns ID of the inference.

Returns:

  • (String)

    ID of the inference.



18
19
20
# File 'lib/mindee/v2/parsing/base_inference.rb', line 18

def id
  @id
end

#jobInferenceJob (readonly)

Returns Metadata about the job.

Returns:

  • (InferenceJob)

    Metadata about the job.



12
13
14
# File 'lib/mindee/v2/parsing/base_inference.rb', line 12

def job
  @job
end

#modelParsing::V2::InferenceModel (readonly)

Returns Model info for the inference.

Returns:



14
15
16
# File 'lib/mindee/v2/parsing/base_inference.rb', line 14

def model
  @model
end

Instance Method Details

#to_sString

String representation.

Returns:

  • (String)


32
33
34
35
36
37
38
39
40
# File 'lib/mindee/v2/parsing/base_inference.rb', line 32

def to_s
  [
    'Inference',
    '#########',
    @job.to_s,
    @model.to_s,
    @file.to_s,
  ].join("\n")
end