class Ubi::Memoria::Document
Show me your papers!
en.wikipedia.org/wiki/National_identification_number
br: CNPJ us: SSN cl: RUN/RUT
Attributes
number[R]
Public Class Methods
formats()
click to toggle source
# File lib/ubi/memorias/document.rb, line 34 def formats { br: [/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/, '\1.\2.\3/\4-\5'], cl: [/(\d{2})(\d{3})(\d{3})(\d{1})/, '\1.\2.\3-\4'], us: [/(\d{3})(\d{2})(\d{4})/, '\1-\2-\3'] } end
regex(location = :br)
click to toggle source
# File lib/ubi/memorias/document.rb, line 42 def regex(location = :br) regexes[location] end
regexes()
click to toggle source
# File lib/ubi/memorias/document.rb, line 26 def regexes { br: /(\d{14}|\d{2}\.?\d{3}\.?\d{3}\/?\d{4}\-?\d{2})/, cl: /\d{2}\.\d{3}\.\d{3}[-][0-9kK]/, us: /\d{3}[-]\d{2}[-]\d{4}/ } end
Public Instance Methods
format(location = :br)
click to toggle source
# File lib/ubi/memorias/document.rb, line 18 def format(location = :br) number.sub(*self.class.formats[location]) end
parser()
click to toggle source
# File lib/ubi/memorias/document.rb, line 14 def parser @number = text.gsub(/\D/, '') end