module BoletoIntermedium
Constants
- VERSION
Attributes
configuration[RW]
Public Class Methods
configure() { |configuration || configuration| ... }
click to toggle source
# File lib/BoletoIntermedium.rb, line 11 def self.configure @configuration ||= Configuration.new yield(configuration || @configuration) @configuration end
Private Class Methods
bank_epoque(date)
click to toggle source
# File lib/BoletoIntermedium.rb, line 45 def self.bank_epoque(date) (date - Date.new(1997,10,7)).to_i end
module_10(str)
click to toggle source
# File lib/BoletoIntermedium.rb, line 49 def self.module_10(str) str = str.chars.reverse i = 2 sum = 0 res = 0 str.each do |char| res = char.to_i * i sum += res > 9 ? (res - 9) : res i = i == 2 ? 1 : 2 end if (sum % 10) == 0 0 else 10 - (sum % 10) end end
module_11(str)
click to toggle source
# File lib/BoletoIntermedium.rb, line 68 def self.module_11(str) peso = 2 soma = 0 str = str.chars.reverse str.each do |char| soma += char.to_i * peso peso = (peso == 9) ? 2 : peso + 1 end if soma % 11 == 0 1 else 11 - (soma % 11) end end