Class: Mindee::V2::Product::Extraction::Params::DataSchemaField
- Inherits:
-
Object
- Object
- Mindee::V2::Product::Extraction::Params::DataSchemaField
- Defined in:
- lib/mindee/v2/product/extraction/params/data_schema_field.rb
Overview
Data Schema Field.
Instance Attribute Summary collapse
-
#classification_values ⇒ Array<String>?
readonly
Allowed values when type is
classification. -
#description ⇒ String?
readonly
Detailed description of what this field represents.
-
#guidelines ⇒ String?
readonly
Optional extraction guidelines.
-
#is_array ⇒ Boolean
readonly
Whether this field can contain multiple values.
-
#name ⇒ String
readonly
Name of the field in the data schema.
-
#nested_fields ⇒ Array<Hash>?
readonly
Nested fields.
-
#title ⇒ String
readonly
Display name for the field, also impacts inference results.
-
#type ⇒ String
readonly
Data type of the field.
-
#unique_values ⇒ Boolean?
readonly
Only applicable if
is_arrayis True.
Instance Method Summary collapse
-
#initialize(field) ⇒ DataSchemaField
constructor
A new instance of DataSchemaField.
- #to_hash ⇒ Hash
- #to_s ⇒ String
Constructor Details
#initialize(field) ⇒ DataSchemaField
Returns a new instance of DataSchemaField.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mindee/v2/product/extraction/params/data_schema_field.rb', line 31 def initialize(field) field.transform_keys!(&:to_sym) @name = field[:name] @title = field[:title] @is_array = field[:is_array] @type = field[:type] @classification_values = field[:classification_values] @unique_values = field[:unique_values] @description = field[:description] @guidelines = field[:guidelines] @nested_fields = field[:nested_fields] end |
Instance Attribute Details
#classification_values ⇒ Array<String>? (readonly)
Returns Allowed values when type is classification. Leave empty for other types.
19 20 21 |
# File 'lib/mindee/v2/product/extraction/params/data_schema_field.rb', line 19 def classification_values @classification_values end |
#description ⇒ String? (readonly)
Returns Detailed description of what this field represents.
24 25 26 |
# File 'lib/mindee/v2/product/extraction/params/data_schema_field.rb', line 24 def description @description end |
#guidelines ⇒ String? (readonly)
Returns Optional extraction guidelines.
26 27 28 |
# File 'lib/mindee/v2/product/extraction/params/data_schema_field.rb', line 26 def guidelines @guidelines end |
#is_array ⇒ Boolean (readonly)
Returns Whether this field can contain multiple values.
15 16 17 |
# File 'lib/mindee/v2/product/extraction/params/data_schema_field.rb', line 15 def is_array @is_array end |
#name ⇒ String (readonly)
Returns Name of the field in the data schema.
13 14 15 |
# File 'lib/mindee/v2/product/extraction/params/data_schema_field.rb', line 13 def name @name end |
#nested_fields ⇒ Array<Hash>? (readonly)
Returns Nested fields.
28 29 30 |
# File 'lib/mindee/v2/product/extraction/params/data_schema_field.rb', line 28 def nested_fields @nested_fields end |
#title ⇒ String (readonly)
Returns Display name for the field, also impacts inference results.
11 12 13 |
# File 'lib/mindee/v2/product/extraction/params/data_schema_field.rb', line 11 def title @title end |
#type ⇒ String (readonly)
Returns Data type of the field.
17 18 19 |
# File 'lib/mindee/v2/product/extraction/params/data_schema_field.rb', line 17 def type @type end |
#unique_values ⇒ Boolean? (readonly)
Only applicable if is_array is True.
22 23 24 |
# File 'lib/mindee/v2/product/extraction/params/data_schema_field.rb', line 22 def unique_values @unique_values end |
Instance Method Details
#to_hash ⇒ Hash
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/mindee/v2/product/extraction/params/data_schema_field.rb', line 45 def to_hash out = { name: @name, title: @title, is_array: @is_array, type: @type, } # @type var out: Hash[Symbol, untyped] out[:classification_values] = @classification_values unless @classification_values.nil? out[:unique_values] = @unique_values unless @unique_values.nil? out[:description] = @description unless @description.nil? out[:guidelines] = @guidelines unless @guidelines.nil? out[:nested_fields] = @nested_fields unless @nested_fields.nil? out end |
#to_s ⇒ String
61 62 63 |
# File 'lib/mindee/v2/product/extraction/params/data_schema_field.rb', line 61 def to_s to_hash.to_json end |