Class: BrDanfe::DanfeLib::NfeLib::Phone

Inherits:
Object
  • Object
show all
Defined in:
lib/br_danfe/danfe_lib/nfe_lib/phone.rb

Class Method Summary collapse

Class Method Details

.format(phone) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/br_danfe/danfe_lib/nfe_lib/phone.rb', line 5

def self.format(phone)
  if phone.length == 10
    phone.sub(/(\d{2})(\d{4})(\d{4})/, '(\\1) \\2-\\3')
  else
    phone.sub(/(\d{2})(\d{5})(\d{4})/, '(\\1) \\2-\\3')
  end
end