Class: EmailHunter::Finder

Inherits:
Object
  • Object
show all
Defined in:
lib/email_hunter/finder.rb

Constant Summary collapse

API_FINDER_URL =
'https://api.hunter.io/v2/email-finder'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain, first_name, last_name, key) ⇒ Finder

Returns a new instance of Finder.



12
13
14
15
16
17
# File 'lib/email_hunter/finder.rb', line 12

def initialize(domain, first_name, last_name, key)
  @domain = domain
  @first_name = first_name
  @last_name = last_name
  @key = key
end

Instance Attribute Details

#domainObject (readonly)

Returns the value of attribute domain.



10
11
12
# File 'lib/email_hunter/finder.rb', line 10

def domain
  @domain
end

#emailObject (readonly)

Returns the value of attribute email.



10
11
12
# File 'lib/email_hunter/finder.rb', line 10

def email
  @email
end

#first_nameObject (readonly)

Returns the value of attribute first_name.



10
11
12
# File 'lib/email_hunter/finder.rb', line 10

def first_name
  @first_name
end

#keyObject (readonly)

Returns the value of attribute key.



10
11
12
# File 'lib/email_hunter/finder.rb', line 10

def key
  @key
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



10
11
12
# File 'lib/email_hunter/finder.rb', line 10

def last_name
  @last_name
end

#metaObject (readonly)

Returns the value of attribute meta.



10
11
12
# File 'lib/email_hunter/finder.rb', line 10

def meta
  @meta
end

#scoreObject (readonly)

Returns the value of attribute score.



10
11
12
# File 'lib/email_hunter/finder.rb', line 10

def score
  @score
end

#sourcesObject (readonly)

Returns the value of attribute sources.



10
11
12
# File 'lib/email_hunter/finder.rb', line 10

def sources
  @sources
end

Instance Method Details

#dataObject



23
24
25
26
27
28
29
30
31
# File 'lib/email_hunter/finder.rb', line 23

def data
  @data ||= begin
    response = fetch_finder_data

    return {} unless response.success?

    JSON.parse(response.body, symbolize_names: true)
  end
end

#huntObject



19
20
21
# File 'lib/email_hunter/finder.rb', line 19

def hunt
  Struct.new(*data.keys).new(*data.values)
end