Class: EmailPredictor::Rules
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #first_initial_dot_last_initial ⇒ Object
- #first_initial_dot_last_name ⇒ Object
- #first_name ⇒ Object
- #first_name_dot_last_initial ⇒ Object
- #first_name_dot_last_name ⇒ Object
- #first_name_initial ⇒ Object
-
#initialize(opts = {}) ⇒ Rules
constructor
A new instance of Rules.
- #last_name ⇒ Object
- #last_name_initial ⇒ Object
- #predict ⇒ Object
- #some_fake_rule ⇒ Object
- #username_first ⇒ Object
- #username_last ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(opts = {}) ⇒ Rules
Returns a new instance of Rules.
7 8 9 10 11 |
# File 'lib/email_predictor/rules.rb', line 7 def initialize(opts = {}) super @username = opts[:username] validate! end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/email_predictor/rules.rb', line 5 def name @name end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
5 6 7 |
# File 'lib/email_predictor/rules.rb', line 5 def username @username end |
Class Method Details
.get(employees) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/email_predictor/rules.rb', line 70 def get(employees) employees.collect do |employee| rule = new(employee) rule.predict end.uniq end |
Instance Method Details
#first_initial_dot_last_initial ⇒ Object
29 30 31 |
# 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 ⇒ Object
25 26 27 |
# File 'lib/email_predictor/rules.rb', line 25 def first_initial_dot_last_name "#{first_name_initial}.#{last_name}" end |
#first_name ⇒ Object
33 34 35 |
# File 'lib/email_predictor/rules.rb', line 33 def first_name @name.split(' ').first end |
#first_name_dot_last_initial ⇒ Object
21 22 23 |
# 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 ⇒ Object
17 18 19 |
# File 'lib/email_predictor/rules.rb', line 17 def first_name_dot_last_name "#{first_name}.#{last_name}" end |
#first_name_initial ⇒ Object
41 42 43 |
# File 'lib/email_predictor/rules.rb', line 41 def first_name_initial first_name[0,1] end |
#last_name ⇒ Object
37 38 39 |
# File 'lib/email_predictor/rules.rb', line 37 def last_name @name.split(' ').last end |
#last_name_initial ⇒ Object
45 46 47 |
# File 'lib/email_predictor/rules.rb', line 45 def last_name_initial last_name[0,1] end |
#predict ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# 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 ⇒ Object
13 14 15 |
# File 'lib/email_predictor/rules.rb', line 13 def some_fake_rule "Holla!" end |
#username_first ⇒ Object
49 50 51 |
# File 'lib/email_predictor/rules.rb', line 49 def username_first @username.split('.').first end |
#username_last ⇒ Object
53 54 55 |
# File 'lib/email_predictor/rules.rb', line 53 def username_last @username.split('.').last end |