Class: Mindee::Parsing::Standard::Taxes

Inherits:
Array
  • Object
show all
Defined in:
lib/mindee/parsing/standard/tax_field.rb

Overview

Represents tax information, grouped as an array.

Instance Method Summary collapse

Constructor Details

#initialize(prediction, page_id) ⇒ Taxes

Returns a new instance of Taxes.

Parameters:

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


75
76
77
# File 'lib/mindee/parsing/standard/tax_field.rb', line 75

def initialize(prediction, page_id)
  super(prediction.map { |entry| TaxField.new(entry, page_id) })
end

Instance Method Details

#line_separator(char) ⇒ String

Parameters:

  • char (String)

Returns:

  • (String)


81
82
83
84
85
86
87
88
89
90
# File 'lib/mindee/parsing/standard/tax_field.rb', line 81

def line_separator(char)
  out_str = String.new
  out_str << '  '
  out_str << "+#{char * 15}"
  out_str << "+#{char * 8}"
  out_str << "+#{char * 10}"
  out_str << "+#{char * 15}"
  out_str << '+'
  out_str
end

#to_sString

Returns:

  • (String)


93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/mindee/parsing/standard/tax_field.rb', line 93

def to_s
  return '' if nil? || empty?

  out_str = String.new
  out_str << ("\n#{line_separator('-')}")
  out_str << "\n  | Base          | Code   | Rate (%) | Amount        |"
  out_str << "\n#{line_separator('=')}"
  each do |entry|
    out_str << "\n  #{entry.to_table_line}\n#{line_separator('-')}"
  end
  out_str
end