Class: Mindee::Parsing::Standard::AmountField

Inherits:
BaseField show all
Defined in:
lib/mindee/parsing/standard/amount_field.rb

Overview

Represents tax information.

Instance Attribute Summary collapse

Attributes inherited from BaseField

#reconstructed

Attributes inherited from AbstractField

#bounding_box, #confidence, #page_id, #polygon

Instance Method Summary collapse

Methods inherited from AbstractField

array_confidence, array_sum, float_to_string

Constructor Details

#initialize(prediction, page_id, reconstructed: false) ⇒ AmountField

Returns a new instance of AmountField.



14
15
16
17
# File 'lib/mindee/parsing/standard/amount_field.rb', line 14

def initialize(prediction, page_id, reconstructed: false)
  super
  @value = @value.to_f.round(3).to_f unless @value.to_s.empty?
end

Instance Attribute Details

#valueFloat? (readonly)

Amount value as 3 decimal float

Returns:

  • (Float, nil)


12
13
14
# File 'lib/mindee/parsing/standard/amount_field.rb', line 12

def value
  @value
end

Instance Method Details

#to_sString

Returns:

  • (String)


20
21
22
# File 'lib/mindee/parsing/standard/amount_field.rb', line 20

def to_s
  @value.nil? ? '' : BaseField.float_to_string(@value.to_f)
end