Class: Mindee::Parsing::V2::Field::SimpleField
- Defined in:
- lib/mindee/parsing/v2/field/simple_field.rb
Overview
A simple field with a scalar value.
Instance Attribute Summary collapse
-
#value ⇒ String, ...
readonly
Value contained in the field.
Attributes inherited from BaseField
#confidence, #indent_level, #locations
Instance Method Summary collapse
-
#initialize(server_response, indent_level = 0) ⇒ SimpleField
constructor
A new instance of SimpleField.
-
#to_s ⇒ String
String representation of the field value.
Methods inherited from BaseField
Constructor Details
#initialize(server_response, indent_level = 0) ⇒ SimpleField
Returns a new instance of SimpleField.
16 17 18 19 20 21 22 23 24 |
# File 'lib/mindee/parsing/v2/field/simple_field.rb', line 16 def initialize(server_response, indent_level = 0) super value = server_response['value'] @value = if value.is_a?(Integer) value.to_f else value end end |
Instance Attribute Details
#value ⇒ String, ... (readonly)
Returns Value contained in the field.
12 13 14 |
# File 'lib/mindee/parsing/v2/field/simple_field.rb', line 12 def value @value end |
Instance Method Details
#to_s ⇒ String
String representation of the field value.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mindee/parsing/v2/field/simple_field.rb', line 28 def to_s return '' if @value.nil? if @value.is_a?(TrueClass) || @value.is_a?(FalseClass) @value ? 'True' : 'False' elsif @value.is_a?(Integer) || @value.is_a?(Float) num = @value # @type var num: Integer | Float format_numeric_value(num) else @value.to_s end end |