Class: Mayaml::MailAccount::PortValidator
- Inherits:
-
Object
- Object
- Mayaml::MailAccount::PortValidator
- Defined in:
- lib/mayaml/mail_account/port_validator.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(port) ⇒ PortValidator
constructor
A new instance of PortValidator.
- #valid? ⇒ Boolean
Constructor Details
#initialize(port) ⇒ PortValidator
Returns a new instance of PortValidator.
25 26 27 28 29 30 |
# File 'lib/mayaml/mail_account/port_validator.rb', line 25 def initialize(port) @errors = [] port = port.respond_to?(:to_i) ? port.to_i : 0 @errors << "Mail account port is invalid." if port == 0 @errors << "Mail account port could not be negative." if port < 0 end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
23 24 25 |
# File 'lib/mayaml/mail_account/port_validator.rb', line 23 def errors @errors end |
Instance Method Details
#valid? ⇒ Boolean
32 33 34 |
# File 'lib/mayaml/mail_account/port_validator.rb', line 32 def valid? @errors.empty? end |