Class: EmailPredictor::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/email_predictor/base.rb

Direct Known Subclasses

Predictor, Rules

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (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