class ContactDetective::Phonenumbers
Public Class Methods
getallnumbers(text)
click to toggle source
# File lib/ContactDetective.rb, line 58 def self.getallnumbers(text) pattone = text.scan(/[0-9]{3}\-[0-9]{3}\-[0-9]{4}/) patttwo = text.scan(/\([0-9]{3}\)\-[0-9]{3}\-[0-9]{3}/) pattthree = text.scan(/[0-9]{3} [0-9]{3} [0-9]{4}/) return pattone + pattwo end
getnumbersbyarea(text, areacode)
click to toggle source
gets numbers by area code
# File lib/ContactDetective.rb, line 65 def self.getnumbersbyarea(text, areacode) string = areacode + '\-[0-9]{3}\-[0-9]{4}' patt = Regexp.new(string) text.scan(patt) end
getwithoutarea(text, areacode)
click to toggle source
all numbers without a specific area
# File lib/ContactDetective.rb, line 71 def self.getwithoutarea(text, areacode) nums = text.scan(/[0-9]{3}\-[0-9]{3}\-[0-9]{4}/) antipatt = Regexp.new(areacode + '\-[0-9]{3}\-[0-9]{4}') nums.reject {|elem| elem =~ antipatt} end