module Phony::Vanity
Helper module that maps vanity numbers to digit numbers.
Public Class Methods
mapping()
click to toggle source
Returns a char to number mapping string for the String#tr method.
# File lib/phony/vanity.rb, line 9 def self.mapping @@mapping ||= [ 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.freeze, '2223334445556667777888999922233344455566677778889999'.freeze ] end
normalized(number)
click to toggle source
# File lib/phony/vanity.rb, line 33 def self.normalized number number.gsub @@vanity_normalizing_regexp, '' end
replace(number)
click to toggle source
Replaces (and normalizes) vanity characters of passed number with correct digits.
# File lib/phony/vanity.rb, line 18 def self.replace number number.tr(*mapping) end
vanity?(number)
click to toggle source
# File lib/phony/vanity.rb, line 26 def self.vanity? number !(normalized(number) =~ @@vanity_regexp).nil? end