class EmailPredictor::Rules
Attributes
name[R]
username[R]
Public Class Methods
get(employees)
click to toggle source
# File lib/email_predictor/rules.rb, line 70 def get(employees) employees.collect do |employee| rule = new(employee) rule.predict end.uniq end
new(opts = {})
click to toggle source
Calls superclass method
EmailPredictor::Base::new
# File lib/email_predictor/rules.rb, line 7 def initialize(opts = {}) super @username = opts[:username] validate! end
Public Instance Methods
first_initial_dot_last_initial()
click to toggle source
# File lib/email_predictor/rules.rb, line 29 def first_initial_dot_last_initial "#{first_name_initial}.#{last_name_initial}" end
first_initial_dot_last_name()
click to toggle source
# File lib/email_predictor/rules.rb, line 25 def first_initial_dot_last_name "#{first_name_initial}.#{last_name}" end
first_name()
click to toggle source
# File lib/email_predictor/rules.rb, line 33 def first_name @name.split(' ').first end
first_name_dot_last_initial()
click to toggle source
# File lib/email_predictor/rules.rb, line 21 def first_name_dot_last_initial "#{first_name}.#{last_name_initial}" end
first_name_dot_last_name()
click to toggle source
# File lib/email_predictor/rules.rb, line 17 def first_name_dot_last_name "#{first_name}.#{last_name}" end
first_name_initial()
click to toggle source
# File lib/email_predictor/rules.rb, line 41 def first_name_initial first_name[0,1] end
last_name()
click to toggle source
# File lib/email_predictor/rules.rb, line 37 def last_name @name.split(' ').last end
last_name_initial()
click to toggle source
# File lib/email_predictor/rules.rb, line 45 def last_name_initial last_name[0,1] end
predict()
click to toggle source
# File lib/email_predictor/rules.rb, line 57 def predict if first_name.eql?(username_first) && last_name.eql?(username_last) 'first_name_dot_last_name' elsif first_name_initial.eql?(username_first) && last_name.eql?(username_last) 'first_initial_dot_last_name' elsif first_name_initial.eql?(username_first) && last_name_initial.eql?(username_last) 'first_initial_dot_last_initial' elsif first_name.eql?(username_first) && last_name_initial.eql?(username_last) 'first_name_dot_last_initial' end end
some_fake_rule()
click to toggle source
# File lib/email_predictor/rules.rb, line 13 def some_fake_rule "Holla!" end
username_first()
click to toggle source
# File lib/email_predictor/rules.rb, line 49 def username_first @username.split('.').first end
username_last()
click to toggle source
# File lib/email_predictor/rules.rb, line 53 def username_last @username.split('.').last end