Class: Laranja::Documento

Inherits:
Generator show all
Defined in:
lib/laranja/generators/pt-BR/documento.rb

Constant Summary

Constants inherited from Generator

Generator::ALL, Generator::NUMBERS

Class Method Summary collapse

Class Method Details

.cpf(uf = nil) ⇒ Object



4
5
6
7
# File 'lib/laranja/generators/pt-BR/documento.rb', line 4

def cpf(uf = nil)
  number = strf('########') + uf_code(uf)
  number + verification_digits(number).join
end

.cpf_formatado(uf = nil) ⇒ Object



9
10
11
12
# File 'lib/laranja/generators/pt-BR/documento.rb', line 9

def cpf_formatado(uf = nil)
  c = cpf(uf)
  '%03d.%03d.%03d-%02d' % [ c[0..2].to_i, c[3..5].to_i, c[6..8].to_i, c[9..10].to_i ]
end

.rgObject



14
15
16
# File 'lib/laranja/generators/pt-BR/documento.rb', line 14

def rg
  strf('#########')
end

.rg_formatadoObject



18
19
20
# File 'lib/laranja/generators/pt-BR/documento.rb', line 18

def rg_formatado
  strf('##.###.###-#')
end