Class: Mindee::V2::Product::Crop::CropItem
- Inherits:
-
Object
- Object
- Mindee::V2::Product::Crop::CropItem
- Defined in:
- lib/mindee/v2/product/crop/crop_item.rb
Overview
Result of a cropped document region.
Instance Attribute Summary collapse
-
#extraction_response ⇒ Object
readonly
Returns the value of attribute extraction_response.
-
#location ⇒ V2::Parsing::Field::FieldLocation
readonly
Coordinates of the detected object on the document.
-
#object_type ⇒ String
readonly
Type or classification of the detected object.
Instance Method Summary collapse
-
#extract_from_file(input_source) ⇒ ExtractedImage
Extract all crop items from this page.
-
#initialize(server_response) ⇒ CropItem
constructor
A new instance of CropItem.
-
#to_s ⇒ String
String representation.
Constructor Details
#initialize(server_response) ⇒ CropItem
Returns a new instance of CropItem.
16 17 18 19 20 21 22 23 24 |
# File 'lib/mindee/v2/product/crop/crop_item.rb', line 16 def initialize(server_response) @object_type = server_response['object_type'] @location = Mindee::V2::Parsing::Field::FieldLocation.new(server_response['location']) # 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
#extraction_response ⇒ Object (readonly)
Returns the value of attribute extraction_response.
13 14 15 |
# File 'lib/mindee/v2/product/crop/crop_item.rb', line 13 def extraction_response @extraction_response end |
#location ⇒ V2::Parsing::Field::FieldLocation (readonly)
Returns Coordinates of the detected object on the document.
12 13 14 |
# File 'lib/mindee/v2/product/crop/crop_item.rb', line 12 def location @location end |
#object_type ⇒ String (readonly)
Returns Type or classification of the detected object.
10 11 12 |
# File 'lib/mindee/v2/product/crop/crop_item.rb', line 10 def object_type @object_type end |
Instance Method Details
#extract_from_file(input_source) ⇒ ExtractedImage
Extract all crop items from this page
36 37 38 39 40 |
# File 'lib/mindee/v2/product/crop/crop_item.rb', line 36 def extract_from_file(input_source) Image::ImageExtractor.extract_multiple_images_from_source( input_source, @location.page, [@location.polygon] )[0] end |
#to_s ⇒ String
String representation.
28 29 30 |
# File 'lib/mindee/v2/product/crop/crop_item.rb', line 28 def to_s "* :Location: #{location}\n :Object Type: #{object_type}" end |