Class: W3CValidators::Results
- Inherits:
-
Object
- Object
- W3CValidators::Results
- Defined in:
- lib/w3c_validators/results.rb
Instance Attribute Summary collapse
-
#charset ⇒ Object
readonly
Returns the value of attribute charset.
-
#checked_by ⇒ Object
readonly
Returns the value of attribute checked_by.
-
#css_level ⇒ Object
readonly
Returns the value of attribute css_level.
-
#debug_messages ⇒ Object
readonly
Returns the value of attribute debug_messages.
-
#doctype ⇒ Object
readonly
Returns the value of attribute doctype.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#validity ⇒ Object
readonly
Returns the value of attribute validity.
Instance Method Summary collapse
- #add_debug_message(key, val) ⇒ Object
- #add_error(params = {}) ⇒ Object
- #add_message(type, params = {}) ⇒ Object
- #add_warning(params = {}) ⇒ Object
-
#checked_against ⇒ Object
Returns either the
DOCTYPE
or CSS level, whichever is present. -
#errors ⇒ Object
Returns an array of Message objects.
-
#initialize(options = {}) ⇒ Results
constructor
A new instance of Results.
- #is_valid? ⇒ Boolean
-
#warnings ⇒ Object
Returns an array of Message objects.
Constructor Details
#initialize(options = {}) ⇒ Results
Returns a new instance of Results.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/w3c_validators/results.rb', line 5 def initialize( = {}) @messages = [] @uri = [:uri] @checked_by = [:checked_by] @doctype = [:doctype] @css_level = [:css_level] @charset = [:charset] if [:validity].kind_of?(String) @validity = [:validity].downcase.strip == 'true' else @validity = [:validity] end @debug_messages = {} end |
Instance Attribute Details
#charset ⇒ Object (readonly)
Returns the value of attribute charset.
3 4 5 |
# File 'lib/w3c_validators/results.rb', line 3 def charset @charset end |
#checked_by ⇒ Object (readonly)
Returns the value of attribute checked_by.
3 4 5 |
# File 'lib/w3c_validators/results.rb', line 3 def checked_by @checked_by end |
#css_level ⇒ Object (readonly)
Returns the value of attribute css_level.
3 4 5 |
# File 'lib/w3c_validators/results.rb', line 3 def css_level @css_level end |
#debug_messages ⇒ Object (readonly)
Returns the value of attribute debug_messages.
3 4 5 |
# File 'lib/w3c_validators/results.rb', line 3 def @debug_messages end |
#doctype ⇒ Object (readonly)
Returns the value of attribute doctype.
3 4 5 |
# File 'lib/w3c_validators/results.rb', line 3 def doctype @doctype end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
3 4 5 |
# File 'lib/w3c_validators/results.rb', line 3 def uri @uri end |
#validity ⇒ Object (readonly)
Returns the value of attribute validity.
3 4 5 |
# File 'lib/w3c_validators/results.rb', line 3 def validity @validity end |
Instance Method Details
#add_debug_message(key, val) ⇒ Object
33 34 35 |
# File 'lib/w3c_validators/results.rb', line 33 def (key, val) @debug_messages[key] = val end |
#add_error(params = {}) ⇒ Object
25 26 27 |
# File 'lib/w3c_validators/results.rb', line 25 def add_error(params = {}) (:error, params) end |
#add_message(type, params = {}) ⇒ Object
20 21 22 23 |
# File 'lib/w3c_validators/results.rb', line 20 def (type, params = {}) uri = params[:uri] ||= @uri @messages << Message.new(uri, type, params) end |
#add_warning(params = {}) ⇒ Object
29 30 31 |
# File 'lib/w3c_validators/results.rb', line 29 def add_warning(params = {}) (:warning, params) end |
#checked_against ⇒ Object
Returns either the DOCTYPE
or CSS level, whichever is present.
38 39 40 41 42 |
# File 'lib/w3c_validators/results.rb', line 38 def checked_against return @doctype if @doctype return @css_level if @css_level nil end |
#errors ⇒ Object
Returns an array of Message objects.
49 50 51 52 53 |
# File 'lib/w3c_validators/results.rb', line 49 def errors errors = [] @messages.each { |msg| errors << msg if msg.is_error? } errors end |
#is_valid? ⇒ Boolean
44 45 46 |
# File 'lib/w3c_validators/results.rb', line 44 def is_valid? @validity end |
#warnings ⇒ Object
Returns an array of Message objects.
56 57 58 59 60 |
# File 'lib/w3c_validators/results.rb', line 56 def warnings errors = [] @messages.each { |msg| errors << msg if msg.is_warning? } errors end |