Class: CED::Email

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

Instance Method Summary collapse

Constructor Details

#initialize(address, host = ENV['CED_HOST'], client = ENV['CED_CLIENT'], key = ENV['CED_KEY']) ⇒ Email

Returns a new instance of Email.

Raises:

  • (ArgumentError)


3
4
5
6
7
8
9
10
11
12
# File 'lib/ced/email.rb', line 3

def initialize(address, host = ENV['CED_HOST'], client = ENV['CED_CLIENT'], key = ENV['CED_KEY'])
  raise ArgumentError, "Missing address"    if address.nil? || address.strip.empty?
  raise ArgumentError, "Missing CED host"   if host.nil?    || host.strip.empty?
  raise ArgumentError, "Missing CED client" if client.nil?  || client.strip.empty?
  raise ArgumentError, "Missing CED key"    if key.nil?     || key.strip.empty?
  @address = address
  @host    = host
  @client  = client
  @key     = key
end

Instance Method Details

#corrected_emailObject



18
19
20
# File 'lib/ced/email.rb', line 18

def corrected_email
  raw_email["email"] || ""
end

#errorObject



30
31
32
# File 'lib/ced/email.rb', line 30

def error
  raw_email["error"] || ""
end

#error_codeObject



34
35
36
# File 'lib/ced/email.rb', line 34

def error_code
  error.downcase.gsub(/[^a-z0-9\-_]+/, "_")
end

#seen_before?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/ced/email.rb', line 26

def seen_before?
  !!raw_email["db"]
end

#valid?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/ced/email.rb', line 22

def valid?
  !!raw_email["valid"]
end

#verified?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/ced/email.rb', line 14

def verified?
  raw_email.keys.any?
end