Class: Mindee::Input::DataSchemaField
- Inherits:
-
Object
- Object
- Mindee::Input::DataSchemaField
- Defined in:
- lib/mindee/input/data_schema.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.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mindee/input/data_schema.rb', line 28 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.
16 17 18 |
# File 'lib/mindee/input/data_schema.rb', line 16 def classification_values @classification_values end |
#description ⇒ String? (readonly)
Returns Detailed description of what this field represents.
21 22 23 |
# File 'lib/mindee/input/data_schema.rb', line 21 def description @description end |
#guidelines ⇒ String? (readonly)
Returns Optional extraction guidelines.
23 24 25 |
# File 'lib/mindee/input/data_schema.rb', line 23 def guidelines @guidelines end |
#is_array ⇒ Boolean (readonly)
Returns Whether this field can contain multiple values.
12 13 14 |
# File 'lib/mindee/input/data_schema.rb', line 12 def is_array @is_array end |
#name ⇒ String (readonly)
Returns Name of the field in the data schema.
10 11 12 |
# File 'lib/mindee/input/data_schema.rb', line 10 def name @name end |
#nested_fields ⇒ Array<Hash>? (readonly)
Returns Nested fields.
25 26 27 |
# File 'lib/mindee/input/data_schema.rb', line 25 def nested_fields @nested_fields end |
#title ⇒ String (readonly)
Returns Display name for the field, also impacts inference results.
8 9 10 |
# File 'lib/mindee/input/data_schema.rb', line 8 def title @title end |
#type ⇒ String (readonly)
Returns Data type of the field.
14 15 16 |
# File 'lib/mindee/input/data_schema.rb', line 14 def type @type end |
#unique_values ⇒ Boolean? (readonly)
Only applicable if is_array is True.
19 20 21 |
# File 'lib/mindee/input/data_schema.rb', line 19 def unique_values @unique_values end |
Instance Method Details
#to_hash ⇒ Hash
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/mindee/input/data_schema.rb', line 42 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
58 59 60 |
# File 'lib/mindee/input/data_schema.rb', line 58 def to_s to_hash.to_json end |