Class: Trumail::Lookup
- Inherits:
-
Object
- Object
- Trumail::Lookup
- Defined in:
- lib/trumail/lookup.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
- #address ⇒ Object
- #catch_all? ⇒ Boolean
- #deliverable? ⇒ Boolean
- #disposable? ⇒ Boolean
- #domain ⇒ Object
- #full_inbox? ⇒ Boolean
- #gravatar? ⇒ Boolean
- #host_exists? ⇒ Boolean
-
#initialize(email, host: DEFAULT_HOST, format: DEFAULT_FORMAT) ⇒ Lookup
constructor
A new instance of Lookup.
- #to_h ⇒ Object
- #url ⇒ Object
- #username ⇒ Object
- #verify ⇒ Object
Constructor Details
#initialize(email, host: DEFAULT_HOST, format: DEFAULT_FORMAT) ⇒ Lookup
Returns a new instance of Lookup.
14 15 16 17 18 19 20 |
# File 'lib/trumail/lookup.rb', line 14 def initialize(email, host: DEFAULT_HOST, format: DEFAULT_FORMAT) @email = email @host = host @format = format.to_sym @response = nil @hash = {} end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
12 13 14 |
# File 'lib/trumail/lookup.rb', line 12 def email @email end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
12 13 14 |
# File 'lib/trumail/lookup.rb', line 12 def format @format end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
12 13 14 |
# File 'lib/trumail/lookup.rb', line 12 def hash @hash end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
12 13 14 |
# File 'lib/trumail/lookup.rb', line 12 def host @host end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
12 13 14 |
# File 'lib/trumail/lookup.rb', line 12 def response @response end |
Class Method Details
.verify(email, host: DEFAULT_HOST, format: DEFAULT_FORMAT) ⇒ Object
22 23 24 25 26 |
# File 'lib/trumail/lookup.rb', line 22 def self.verify(email, host: DEFAULT_HOST, format: DEFAULT_FORMAT) klass = new(email, host: host, format: format) klass.verify klass end |
Instance Method Details
#address ⇒ Object
45 46 47 |
# File 'lib/trumail/lookup.rb', line 45 def address @hash['address'] end |
#catch_all? ⇒ Boolean
49 50 51 |
# File 'lib/trumail/lookup.rb', line 49 def catch_all? @hash['catchAll'] end |
#deliverable? ⇒ Boolean
53 54 55 |
# File 'lib/trumail/lookup.rb', line 53 def deliverable? @hash['deliverable'] end |
#disposable? ⇒ Boolean
57 58 59 |
# File 'lib/trumail/lookup.rb', line 57 def disposable? @hash['disposable'] end |
#domain ⇒ Object
61 62 63 |
# File 'lib/trumail/lookup.rb', line 61 def domain @hash['domain'] end |
#full_inbox? ⇒ Boolean
65 66 67 |
# File 'lib/trumail/lookup.rb', line 65 def full_inbox? @hash['fullInbox'] end |
#gravatar? ⇒ Boolean
69 70 71 |
# File 'lib/trumail/lookup.rb', line 69 def gravatar? @hash['gravatar'] end |
#host_exists? ⇒ Boolean
73 74 75 |
# File 'lib/trumail/lookup.rb', line 73 def host_exists? @hash['hostExists'] end |
#to_h ⇒ Object
41 42 43 |
# File 'lib/trumail/lookup.rb', line 41 def to_h @hash end |
#url ⇒ Object
37 38 39 |
# File 'lib/trumail/lookup.rb', line 37 def url "#{@host}/#{@format}/#{@email}" end |
#username ⇒ Object
77 78 79 |
# File 'lib/trumail/lookup.rb', line 77 def username @hash['username'] end |
#verify ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/trumail/lookup.rb', line 28 def verify return @hash unless @response.nil? Typhoeus::Config.user_agent = UserAgentDB.random @response = Typhoeus.get(url, accept_encoding: 'gzip,deflate').response_body parse_by_format end |