Class: EmailHunter::Search
- Inherits:
-
Object
- Object
- EmailHunter::Search
- Defined in:
- lib/email_hunter/search.rb
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#emails ⇒ Object
readonly
Returns the value of attribute emails.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
-
#webmail ⇒ Object
readonly
Returns the value of attribute webmail.
Instance Method Summary collapse
- #data ⇒ Object
- #hunt ⇒ Object
-
#initialize(domain, key, params = {}) ⇒ Search
constructor
A new instance of Search.
- #limit ⇒ Object
- #offset ⇒ Object
Constructor Details
#initialize(domain, key, params = {}) ⇒ Search
Returns a new instance of Search.
12 13 14 15 16 |
# File 'lib/email_hunter/search.rb', line 12 def initialize(domain, key, params = {}) @domain = domain @key = key @params = params end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
10 11 12 |
# File 'lib/email_hunter/search.rb', line 10 def domain @domain end |
#emails ⇒ Object (readonly)
Returns the value of attribute emails.
10 11 12 |
# File 'lib/email_hunter/search.rb', line 10 def emails @emails end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
10 11 12 |
# File 'lib/email_hunter/search.rb', line 10 def key @key end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
10 11 12 |
# File 'lib/email_hunter/search.rb', line 10 def @meta end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
10 11 12 |
# File 'lib/email_hunter/search.rb', line 10 def params @params end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
10 11 12 |
# File 'lib/email_hunter/search.rb', line 10 def pattern @pattern end |
#webmail ⇒ Object (readonly)
Returns the value of attribute webmail.
10 11 12 |
# File 'lib/email_hunter/search.rb', line 10 def webmail @webmail end |
Instance Method Details
#data ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/email_hunter/search.rb', line 30 def data @data ||= begin response = Faraday.new("#{API_SEARCH_URL}domain=#{domain}&api_key=#{key}&type=#{params[:type]}&offset=#{offset}&limit=#{limit}").get return {} unless response.success? JSON.parse(response.body, { symbolize_names: true }) end end |
#hunt ⇒ Object
18 19 20 |
# File 'lib/email_hunter/search.rb', line 18 def hunt Struct.new(*data.keys).new(*data.values) end |
#limit ⇒ Object
22 23 24 |
# File 'lib/email_hunter/search.rb', line 22 def limit params[:limit] || 10 end |
#offset ⇒ Object
26 27 28 |
# File 'lib/email_hunter/search.rb', line 26 def offset params[:offset] || 0 end |