Class: EmailPredictor::Base
- Inherits:
-
Object
- Object
- EmailPredictor::Base
- Defined in:
- lib/email_predictor/base.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(opts) ⇒ Base
constructor
A new instance of Base.
-
#validate! ⇒ Object
Validate that the name should be in format of firstname lastname.
Constructor Details
#initialize(opts) ⇒ Base
Returns a new instance of Base.
6 7 8 |
# File 'lib/email_predictor/base.rb', line 6 def initialize(opts) @name = opts[:name].downcase end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/email_predictor/base.rb', line 4 def name @name end |
Instance Method Details
#validate! ⇒ Object
Validate that the name should be in format of firstname lastname
11 12 13 14 15 |
# File 'lib/email_predictor/base.rb', line 11 def validate! unless @name.split(" ").count.eql?(2) raise TypeError.new("Oops, the name is not in valid format. Should be like 'Firstname lastname', Eg: John Ferguson") end end |