Class: Mindee::V2::Parsing::Field::FieldConfidence
- Inherits:
-
Object
- Object
- Mindee::V2::Parsing::Field::FieldConfidence
- Defined in:
- lib/mindee/v2/parsing/field/field_confidence.rb
Overview
Confidence level of a field as returned by the V2 API.
Constant Summary collapse
- CERTAIN =
Absolute certainty about the field's extraction.
'Certain'- HIGH =
High certainty about the field's extraction.
'High'- MEDIUM =
Medium certainty about the field's extraction.
'Medium'- LOW =
Low certainty about the field's extraction.
'Low'- VALID_VALUES =
List of valid values, as frozen strings.
['Certain', 'High', 'Medium', 'Low'].freeze
Instance Attribute Summary collapse
-
#value ⇒ String
readonly
The confidence level value.
Instance Method Summary collapse
-
#<(other) ⇒ Object
(also: #lt?, #less_than?)
Less than comparison of two FieldConfidence instances.
-
#<=(other) ⇒ Object
(also: #lteql?, #less_than_or_equal?)
Less than or equality of two FieldConfidence instances.
-
#==(other) ⇒ Boolean
(also: #eql?, #equal?)
Equality of two FieldConfidence instances.
-
#>(other) ⇒ Object
(also: #gt?, #greater_than?)
Greater than comparison of two FieldConfidence instances.
-
#>=(other) ⇒ Object
(also: #gteql?, #greater_than_or_equal?)
Greater than or equality of two FieldConfidence instances.
-
#initialize(value) ⇒ FieldConfidence
constructor
A new instance of FieldConfidence.
-
#inspect ⇒ String
Inspect method for debugging.
-
#to_i ⇒ Integer
String representation of the confidence level.
-
#to_s ⇒ String
String representation of the confidence level.
Constructor Details
#initialize(value) ⇒ FieldConfidence
Returns a new instance of FieldConfidence.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/mindee/v2/parsing/field/field_confidence.rb', line 26 def initialize(value) case value when 'Certain' then @value = CERTAIN when 'High' then @value = HIGH when 'Medium' then @value = MEDIUM when 'Low' then @value = LOW else raise ArgumentError, "Invalid confidence level: '#{value}'. Must be one of: #{VALID_VALUES.join(', ')}" end @value = value end |
Instance Attribute Details
#value ⇒ String (readonly)
Returns The confidence level value.
10 11 12 |
# File 'lib/mindee/v2/parsing/field/field_confidence.rb', line 10 def value @value end |
Instance Method Details
#<(other) ⇒ Object Also known as: lt?, less_than?
Less than comparison of two FieldConfidence instances.
120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/mindee/v2/parsing/field/field_confidence.rb', line 120 def <(other) if other.is_a?(FieldConfidence) to_i < val_to_i(other.value) elsif other.is_a?(String) to_i < val_to_i(other) elsif other.is_a?(Integer) to_i < other else raise ArgumentError, "Invalid type: #{other.class}" end end |
#<=(other) ⇒ Object Also known as: lteql?, less_than_or_equal?
Less than or equality of two FieldConfidence instances.
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/mindee/v2/parsing/field/field_confidence.rb', line 92 def <=(other) if other.is_a?(FieldConfidence) to_i <= val_to_i(other.value) elsif other.is_a?(String) to_i <= val_to_i(other) elsif other.is_a?(Integer) to_i <= other else raise ArgumentError, "Invalid type: #{other.class}" end end |
#==(other) ⇒ Boolean Also known as: eql?, equal?
Equality of two FieldConfidence instances.
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/mindee/v2/parsing/field/field_confidence.rb', line 64 def ==(other) if other.is_a?(FieldConfidence) @value == other.value elsif other.is_a?(String) @value == other elsif other.is_a?(Integer) to_i == other else raise ArgumentError, "Invalid type: #{other.class}" end end |
#>(other) ⇒ Object Also known as: gt?, greater_than?
Greater than comparison of two FieldConfidence instances.
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/mindee/v2/parsing/field/field_confidence.rb', line 106 def >(other) if other.is_a?(FieldConfidence) to_i > val_to_i(other.value) elsif other.is_a?(String) to_i > val_to_i(other) elsif other.is_a?(Integer) to_i > other else raise ArgumentError, "Invalid type: #{other.class}" end end |
#>=(other) ⇒ Object Also known as: gteql?, greater_than_or_equal?
Greater than or equality of two FieldConfidence instances.
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/mindee/v2/parsing/field/field_confidence.rb', line 78 def >=(other) if other.is_a?(FieldConfidence) to_i >= val_to_i(other.value) elsif other.is_a?(String) to_i >= val_to_i(other) elsif other.is_a?(Integer) to_i >= other else raise ArgumentError, "Invalid type: #{other.class}" end end |
#inspect ⇒ String
Inspect method for debugging.
54 55 56 |
# File 'lib/mindee/v2/parsing/field/field_confidence.rb', line 54 def inspect "#<#{self.class.name}:#{@value}>" end |
#to_i ⇒ Integer
String representation of the confidence level.
48 49 50 |
# File 'lib/mindee/v2/parsing/field/field_confidence.rb', line 48 def to_i val_to_i(@value) end |
#to_s ⇒ String
String representation of the confidence level.
42 43 44 |
# File 'lib/mindee/v2/parsing/field/field_confidence.rb', line 42 def to_s @value end |