Class: Mindee::V2::Product::Crop::CropResponse

Inherits:
Mindee::V2::Parsing::BaseResponse show all
Defined in:
lib/mindee/v2/product/crop/crop_response.rb

Overview

HTTP response wrapper that embeds a V2 Inference.

Instance Attribute Summary collapse

Attributes inherited from Mindee::V2::Parsing::CommonResponse

#raw_http

Instance Method Summary collapse

Constructor Details

#initialize(server_response) ⇒ CropResponse

Returns a new instance of CropResponse.

Parameters:

  • server_response (Hash)

    Hash parsed from the API JSON response.



17
18
19
20
21
# File 'lib/mindee/v2/product/crop/crop_response.rb', line 17

def initialize(server_response)
  super

  @inference = CropInference.new(server_response['inference'])
end

Instance Attribute Details

#inferenceCropInference (readonly)

Returns Parsed inference payload.

Returns:



14
15
16
# File 'lib/mindee/v2/product/crop/crop_response.rb', line 14

def inference
  @inference
end

Instance Method Details

#extract_from_file(input_source) ⇒ FileOperation::CropFiles

Apply the crop inference to a file and return a list of extracted images.

Parameters:

Returns:



33
34
35
# File 'lib/mindee/v2/product/crop/crop_response.rb', line 33

def extract_from_file(input_source)
  FileOperation::Crop.extract_crops(input_source, @inference.result.crops)
end

#to_sString

String representation.

Returns:

  • (String)


25
26
27
# File 'lib/mindee/v2/product/crop/crop_response.rb', line 25

def to_s
  @inference.to_s
end