Class: EmailPredictor::Predictor
- Defined in:
- lib/email_predictor/predictor.rb
Instance Attribute Summary collapse
-
#company ⇒ Object
readonly
Returns the value of attribute company.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#predicted_emails ⇒ Object
readonly
Returns the value of attribute predicted_emails.
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #applicable_rules ⇒ Object
-
#initialize(opts = {}) ⇒ Predictor
constructor
A new instance of Predictor.
- #predict ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(opts = {}) ⇒ Predictor
Returns a new instance of Predictor.
11 12 13 14 15 16 |
# File 'lib/email_predictor/predictor.rb', line 11 def initialize(opts = {}) super @company = opts[:company] @predicted_emails = [] validate! end |
Instance Attribute Details
#company ⇒ Object (readonly)
Returns the value of attribute company.
9 10 11 |
# File 'lib/email_predictor/predictor.rb', line 9 def company @company end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
9 10 11 |
# File 'lib/email_predictor/predictor.rb', line 9 def @message end |
#predicted_emails ⇒ Object (readonly)
Returns the value of attribute predicted_emails.
9 10 11 |
# File 'lib/email_predictor/predictor.rb', line 9 def predicted_emails @predicted_emails end |
Class Method Details
.predict(opts) ⇒ Object
19 20 21 22 |
# File 'lib/email_predictor/predictor.rb', line 19 def predict(opts) obj = new(opts).predict obj end |
Instance Method Details
#applicable_rules ⇒ Object
38 39 40 41 |
# File 'lib/email_predictor/predictor.rb', line 38 def applicable_rules data_analyser = EmailPredictor::DataAnalyser.find(@company) data_analyser ? data_analyser.rules : [] end |
#predict ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/email_predictor/predictor.rb', line 25 def predict obj = EmailPredictor::Rules.new(name: @name) unless applicable_rules.empty? applicable_rules.collect do |rule| @predicted_emails << "#{obj.send(rule)}@#{@company}.com" @message = 'Successfully predicted emails.' end else @message = "Prediction cannot be done for #{@name.titleize} as we don't have any historical data for #{@company} company." end self end |