Class: CED::Email
- Inherits:
-
Object
- Object
- CED::Email
- Defined in:
- lib/ced/email.rb
Instance Method Summary collapse
- #corrected_email ⇒ Object
- #error ⇒ Object
- #error_code ⇒ Object
-
#initialize(address, host = ENV['CED_HOST'], client = ENV['CED_CLIENT'], key = ENV['CED_KEY']) ⇒ Email
constructor
A new instance of Email.
- #seen_before? ⇒ Boolean
- #valid? ⇒ Boolean
- #verified? ⇒ Boolean
Constructor Details
#initialize(address, host = ENV['CED_HOST'], client = ENV['CED_CLIENT'], key = ENV['CED_KEY']) ⇒ Email
Returns a new instance of Email.
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_email ⇒ Object
18 19 20 |
# File 'lib/ced/email.rb', line 18 def corrected_email raw_email["email"] || "" end |
#error ⇒ Object
30 31 32 |
# File 'lib/ced/email.rb', line 30 def error raw_email["error"] || "" end |
#error_code ⇒ Object
34 35 36 |
# File 'lib/ced/email.rb', line 34 def error_code error.downcase.gsub(/[^a-z0-9\-_]+/, "_") end |
#seen_before? ⇒ Boolean
26 27 28 |
# File 'lib/ced/email.rb', line 26 def seen_before? !!raw_email["db"] end |
#valid? ⇒ Boolean
22 23 24 |
# File 'lib/ced/email.rb', line 22 def valid? !!raw_email["valid"] end |
#verified? ⇒ Boolean
14 15 16 |
# File 'lib/ced/email.rb', line 14 def verified? raw_email.keys.any? end |