Class: VerificadorBoletoBr::Slip::Bank::CodeAssembly

Inherits:
Object
  • Object
show all
Includes:
Calculus::Module10, Calculus::Module11
Defined in:
lib/verificador_boleto_br/slip/bank/code_assembly.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Calculus::Module11

#modulo11

Methods included from Calculus::Module10

#modulo10

Constructor Details

#initialize(code) ⇒ CodeAssembly

Returns a new instance of CodeAssembly.



10
11
12
# File 'lib/verificador_boleto_br/slip/bank/code_assembly.rb', line 10

def initialize(code)
  @code = code
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



8
9
10
# File 'lib/verificador_boleto_br/slip/bank/code_assembly.rb', line 8

def code
  @code
end

Instance Method Details

#digitable_lineObject



14
15
16
17
18
19
# File 'lib/verificador_boleto_br/slip/bank/code_assembly.rb', line 14

def digitable_line
  block_1 = code[0..3] + code[19..23] + modulo10(code[0..3] + code[19..23]).to_s
  block_2 = code[24..33] + modulo10(code[24..33]).to_s
  block_3 = code[34..-1] + modulo10(code[34..-1]).to_s
  block_1 + block_2 + block_3 + code[4..18]
end