lib/br_documents/ie/mt.rb in br_documents-0.1.3 vs lib/br_documents/ie/mt.rb in br_documents-0.2.0

- old
+ new

@@ -1,6 +1,6 @@ -require_relative "pattern1" +require_relative 'pattern1' module BrDocuments module IE class MT < Pattern1 def initialize(number) @@ -10,17 +10,18 @@ @mask = /^\d{4}\.?\d{3}\.?\d{3}\-?\d{1}$/ @weight = [3, 2, 9, 8, 7, 6, 5, 4, 3, 2] end private + def generate_zeros(number) - just_numbers = number.gsub(/[\.\/-]/, "") - zeros = ("0" * 11).slice(just_numbers.length, 11) - yield "#{zeros}" if block_given? + just_numbers = number.gsub(/[\.\/-]/, '') + zeros = ('0' * 11).slice(just_numbers.length, 11) + yield zeros.to_s if block_given? end def format_ie(number) - number.sub(/(\d{10})(\d{1})/, "\\1-\\2") + number.sub(/(\d{10})(\d{1})/, '\\1-\\2') end end end end