Class: GlobalPhone::Format
Instance Method Summary
collapse
Methods inherited from Record
field, #initialize
Instance Method Details
#apply(national_string, type) ⇒ Object
21
22
23
24
25
|
# File 'lib/global_phone/format.rb', line 21
def apply(national_string, type)
if replacement = format_replacement_string(type)
national_string.gsub(pattern, replacement)
end
end
|
16
17
18
19
|
# File 'lib/global_phone/format.rb', line 16
def format_replacement_string(type)
format_rule = send(:"#{type}_format_rule")
format_rule.to_s.gsub("$", "\\") unless format_rule == "NA"
end
|
#match(national_string, match_leading_digits = true) ⇒ Object
11
12
13
14
|
# File 'lib/global_phone/format.rb', line 11
def match(national_string, match_leading_digits = true)
return false if match_leading_digits && leading_digits && national_string !~ leading_digits
national_string =~ pattern
end
|