module APIHub::Baller
Constants
- VERSION
Attributes
defaults[RW]
Public Instance Methods
api_key=(value)
click to toggle source
# File lib/apihub/baller.rb, line 24 def api_key=(value) APIHub.api_key = value end
baller?(email, options = {})
click to toggle source
# File lib/apihub/baller.rb, line 28 def baller?(email, options = {}) threshold = options[:threshold] || 20 lookup(options).score > threshold end
lookup(email)
click to toggle source
# File lib/apihub/baller.rb, line 34 def lookup(email) if email =~ /.+@.+/ person = Streaming::Person[email: email] suffix, domain = email.split('@', 2) else domain = email end unless EmailProviders::DOMAINS.include?(domain) company = Streaming::Company[domain: domain] end return unless person || company result = Mash.new(person || {}) result.merge!(company: company) result.merge!(score: score(result)) result end
score(result, options = {})
click to toggle source
# File lib/apihub/baller.rb, line 55 def score(result, options = {}) options = defaults.merge(options) score = 0.0 return score unless result if result.avatar score += 5 end if result.twitter score += result.twitter.followers * options.twitter_followers_weight end if result.angellist score += result.angellist.followers * options.angellist_followers_weight end if result.klout && result.klout.score score += result.klout.score * options.klout_score_weight end if company = result.company unless company.personal score += options.company_score end if company.raised score += company.raised * options.company_raised_weight end if company.employees score += company.employees * options.company_employees_weight end if company.alexa && company.alexa.globalRank score += 1 / (company.alexa.globalRank * options.company_alexa_rank_weight) end if company.google && company.google.rank && company.google.rank > 0 score += 1 / (company.google.rank * options.company_google_rank_weight) end if company.twitter score += company.twitter.followers * options.company_twitter_followers_weight end end score /= options.total_score [score.round(1), 1.0].min end