Class: TellIo::Countries::Usa
Class Method Summary collapse
Class Method Details
.format(phone) ⇒ Object
11 12 13 |
# File 'lib/countries/usa.rb', line 11 def self.format(phone) phone.gsub(/\A\+1(\d{3})(\d{3})(\d{4})\z/, "(\\1) \\2-\\3") end |
.generate ⇒ Object
15 16 17 |
# File 'lib/countries/usa.rb', line 15 def self.generate "+1#{rand(200..999)}#{rand(100..999)}#{rand(1000..9999)}" end |
.valid?(phone) ⇒ Boolean
7 8 9 |
# File 'lib/countries/usa.rb', line 7 def self.valid?(phone) !!(phone =~ /\A\+1\d{10}\z/) end |