Class: LivingValidator::Result
- Inherits:
-
Object
- Object
- LivingValidator::Result
- Defined in:
- lib/living-validator.rb
Overview
Validator results class with convenience functions
Instance Attribute Summary collapse
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#errorCount ⇒ Object
Get the number of errors returned.
-
#errors ⇒ Object
Get only the error messages.
-
#infoCount ⇒ Object
Get the number of info messages returned.
-
#infos ⇒ Object
Get only the info messages.
-
#initialize(url, messages) ⇒ Result
constructor
Construct a new result set from the url and messages.
-
#messageCount ⇒ Object
Get the total messages count.
-
#valid? ⇒ Boolean
Declares a document valid if no error messages were raised.
Constructor Details
#initialize(url, messages) ⇒ Result
Construct a new result set from the url and messages
74 75 76 77 |
# File 'lib/living-validator.rb', line 74 def initialize(url, ) @messages = @url = url end |
Instance Attribute Details
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
68 69 70 |
# File 'lib/living-validator.rb', line 68 def @messages end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
68 69 70 |
# File 'lib/living-validator.rb', line 68 def url @url end |
Instance Method Details
#errorCount ⇒ Object
Get the number of errors returned
88 89 90 |
# File 'lib/living-validator.rb', line 88 def errorCount (self.errors()).length end |
#errors ⇒ Object
Get only the error messages
102 103 104 |
# File 'lib/living-validator.rb', line 102 def errors @messages.select{|msg| msg['type'] == 'error'} end |
#infoCount ⇒ Object
Get the number of info messages returned
95 96 97 |
# File 'lib/living-validator.rb', line 95 def infoCount (self.infos()).length end |
#infos ⇒ Object
Get only the info messages
108 109 110 |
# File 'lib/living-validator.rb', line 108 def infos @messages.select{|msg| msg['type'] == 'info'} end |
#messageCount ⇒ Object
Get the total messages count
115 116 117 |
# File 'lib/living-validator.rb', line 115 def @messages.length end |
#valid? ⇒ Boolean
Declares a document valid if no error messages were raised
81 82 83 |
# File 'lib/living-validator.rb', line 81 def valid? (self.errorCount) == 0? true : false end |