Module: APIHub::LeadScore::Score
Instance Attribute Summary collapse
-
#defaults ⇒ Object
Returns the value of attribute defaults.
Instance Method Summary collapse
Instance Attribute Details
#defaults ⇒ Object
Returns the value of attribute defaults.
4 5 6 |
# File 'lib/apihub/lead_score/score.rb', line 4 def defaults @defaults end |
Instance Method Details
#calculate(result, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/apihub/lead_score/score.rb', line 19 def calculate(result, = {}) = defaults.merge() score = 0.0 return score unless result if person = result.person if person.avatar score += 5 end if person.twitter.followers score += person.twitter.followers * .twitter_followers_weight end if person.angellist.followers score += person.angellist.followers * .angellist_followers_weight end if person.klout.score score += person.klout.score * .klout_score_weight end end if company = result.company unless company.personal score += .company_score end if company.raised score += company.raised * .company_raised_weight end if company.employees score += company.employees * .company_employees_weight end if company.alexa.globalRank score += 1 / (company.alexa.globalRank * .company_alexa_rank_weight) end if company.google.rank && company.google.rank > 0 score += 1 / (company.google.rank * .company_google_rank_weight) end if company.twitter.followers score += company.twitter.followers * .company_twitter_followers_weight end end score /= .total_score [score.round(1), 1.0].min end |