class ContactDetective::Emails

Public Class Methods

emailswithext(text, ext) click to toggle source

gets every email with specific extension

# File lib/ContactDetective.rb, line 45
def self.emailswithext(text, ext)
  string = '[a-zA-Z0-9]+@[a-zA-Z0-9]+\.' + ext
  patt = Regexp.new(string)
  text.scan(patt)
end
emailswithname(text, name) click to toggle source

gets emails with prefix before @ sign

# File lib/ContactDetective.rb, line 51
def self.emailswithname(text, name)
  string = name + '@[a-zA-Z0-9]+\.[a-z]+'
  patt = Regexp.new(string)
  text.scan(patt)
end
getallemails(text) click to toggle source

gets every email in the text

# File lib/ContactDetective.rb, line 41
def self.getallemails(text)
  text.scan(/[a-zA-Z0-9]+@[a-zA-Z0-9]+\.[a-z]+/)
end