Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/rfc822.rb

Instance Method Summary collapse

Instance Method Details

#contains_email?Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
# File 'lib/rfc822.rb', line 29

def contains_email?
  if RUBY_VERSION >= "1.9"
    (self.dup.force_encoding("BINARY") =~ RFC822::EMAIL_REGEXP_PART) != nil
  else
    (self =~ RFC822::EMAIL_REGEXP_PART) != nil
  end
end

#is_email?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
# File 'lib/rfc822.rb', line 21

def is_email?
  if RUBY_VERSION >= "1.9"
    (self.dup.force_encoding("BINARY") =~ RFC822::EMAIL_REGEXP_WHOLE) != nil
  else
    (self =~ RFC822::EMAIL_REGEXP_WHOLE) != nil
  end
end

#scan_for_emailsObject



37
38
39
40
41
42
43
# File 'lib/rfc822.rb', line 37

def scan_for_emails
  if RUBY_VERSION >= "1.9"
    self.dup.force_encoding("BINARY").scan(RFC822::EMAIL_REGEXP_PART)
  else
    self.scan(RFC822::EMAIL_REGEXP_PART)
  end
end