Class: EmailHunter::People
- Inherits:
-
Object
- Object
- EmailHunter::People
- Defined in:
- lib/email_hunter/people.rb
Constant Summary collapse
- API_URL =
'https://api.hunter.io/v2/people/find'
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #hunt ⇒ Object
-
#initialize(email, key) ⇒ People
constructor
A new instance of People.
Constructor Details
#initialize(email, key) ⇒ People
13 14 15 16 |
# File 'lib/email_hunter/people.rb', line 13 def initialize(email, key) @email = email @key = key end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
11 12 13 |
# File 'lib/email_hunter/people.rb', line 11 def email @email end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
11 12 13 |
# File 'lib/email_hunter/people.rb', line 11 def key @key end |
Instance Method Details
#hunt ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/email_hunter/people.rb', line 18 def hunt response_data = fetch_people_data return nil if response_data.empty? # Convert nested data structure to a Struct data = response_data[:data] = response_data[:meta] result = OpenStruct.new( data: OpenStruct.new(data), meta: OpenStruct.new() ) # Recursively convert nested hashes to OpenStructs for deeper access convert_hash_to_struct(result.data, data) result end |