Class: Mindee::Product::FR::Payslip::PayslipV2SalaryDetail

Inherits:
Mindee::Parsing::Standard::FeatureField show all
Includes:
Mindee::Parsing::Standard
Defined in:
lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb

Overview

Detailed information about the earnings.

Instance Attribute Summary collapse

Attributes inherited from Mindee::Parsing::Standard::AbstractField

#bounding_box, #confidence, #page_id, #polygon

Instance Method Summary collapse

Methods inherited from Mindee::Parsing::Standard::FeatureField

#format_for_display

Methods inherited from Mindee::Parsing::Standard::AbstractField

array_confidence, array_sum, float_to_string

Constructor Details

#initialize(prediction, page_id) ⇒ PayslipV2SalaryDetail

Returns a new instance of PayslipV2SalaryDetail.

Parameters:

  • prediction (Hash)
  • page_id (Integer, nil)


27
28
29
30
31
32
33
34
# File 'lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb', line 27

def initialize(prediction, page_id)
  super(prediction, page_id)
  @amount = prediction['amount']
  @base = prediction['base']
  @description = prediction['description']
  @rate = prediction['rate']
  @page_id = page_id
end

Instance Attribute Details

#amountFloat (readonly)

The amount of the earnings.

Returns:

  • (Float)


14
15
16
# File 'lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb', line 14

def amount
  @amount
end

#baseFloat (readonly)

The base value of the earnings.

Returns:

  • (Float)


17
18
19
# File 'lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb', line 17

def base
  @base
end

#descriptionString (readonly)

The description of the earnings.

Returns:

  • (String)


20
21
22
# File 'lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb', line 20

def description
  @description
end

#rateFloat (readonly)

The rate of the earnings.

Returns:

  • (Float)


23
24
25
# File 'lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb', line 23

def rate
  @rate
end

Instance Method Details

#printable_valuesHash

Returns:

  • (Hash)


37
38
39
40
41
42
43
44
# File 'lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb', line 37

def printable_values
  printable = {}
  printable[:amount] = @amount.nil? ? '' : Field.float_to_string(@amount)
  printable[:base] = @base.nil? ? '' : Field.float_to_string(@base)
  printable[:description] = format_for_display(@description)
  printable[:rate] = @rate.nil? ? '' : Field.float_to_string(@rate)
  printable
end

#table_printable_valuesHash

Returns:

  • (Hash)


47
48
49
50
51
52
53
54
# File 'lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb', line 47

def table_printable_values
  printable = {}
  printable[:amount] = @amount.nil? ? '' : Field.float_to_string(@amount)
  printable[:base] = @base.nil? ? '' : Field.float_to_string(@base)
  printable[:description] = format_for_display(@description, 36)
  printable[:rate] = @rate.nil? ? '' : Field.float_to_string(@rate)
  printable
end

#to_sString

Returns:

  • (String)


68
69
70
71
72
73
74
75
76
# File 'lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb', line 68

def to_s
  printable = printable_values
  out_str = String.new
  out_str << "\n  :Amount: #{printable[:amount]}"
  out_str << "\n  :Base: #{printable[:base]}"
  out_str << "\n  :Description: #{printable[:description]}"
  out_str << "\n  :Rate: #{printable[:rate]}"
  out_str
end

#to_table_lineString

Returns:

  • (String)


57
58
59
60
61
62
63
64
65
# File 'lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb', line 57

def to_table_line
  printable = table_printable_values
  out_str = String.new
  out_str << format('| %- 13s', printable[:amount])
  out_str << format('| %- 10s', printable[:base])
  out_str << format('| %- 37s', printable[:description])
  out_str << format('| %- 10s', printable[:rate])
  out_str << '|'
end