Class: BRDocuments::IE::AP

Inherits:
Base
  • Object
show all
Defined in:
lib/br_documents/documents/ie/ap.rb

Constant Summary collapse

RANGE_VALUES =

In RANGE_VALUES we remove the first ‘0’ character so numbers are’t treated as octal numberss see: :obtain_range_aux_value method

{
  3000001..3017000 => [5, 0],
  3017001..3019022 => [9, 1]
}.freeze
DEFAULT_RANGE_CONF =
[0, 0]

Constants inherited from Base

Base::FIXED_INITIAL_NUMBERS, Base::INITIAL_FIX_NUMBERS_POSITION

Instance Method Summary collapse

Methods inherited from Base

fixed_digits, fixed_digits_positions, generate_root_numbers, set_fixed_digits, #valid?, valid_fixed_digits?, #valid_fixed_digits?, #validate_fixed_digits?

Instance Method Details

#calc_verify_digit(quotient_rest) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/br_documents/documents/ie/ap.rb', line 36

def calc_verify_digit(quotient_rest)
  if ([11].member?(get_division_modulo - quotient_rest))
    return range_aux_values_hash[:d]
  end

  super
end

#range_aux_values_hashObject



23
24
25
26
27
28
29
30
# File 'lib/br_documents/documents/ie/ap.rb', line 23

def range_aux_values_hash
  range_conf = obtain_range_aux_value(@number.dup)

  {
    :p => range_conf[0],
    :d => range_conf[1]
  } # equivalent to Hash[[:p, :d].zip(range_conf)]
end

#reduce_digits_weights(number, weights) ⇒ Object



32
33
34
# File 'lib/br_documents/documents/ie/ap.rb', line 32

def reduce_digits_weights(number, weights)
  range_aux_values_hash[:p] + super(number, weights)
end