Class: Govspeak::HtmlValidator
- Inherits:
-
Object
- Object
- Govspeak::HtmlValidator
- Defined in:
- lib/govspeak/html_validator.rb
Instance Attribute Summary collapse
-
#govspeak_string ⇒ Object
readonly
Returns the value of attribute govspeak_string.
Instance Method Summary collapse
-
#initialize(govspeak_string, options = {}) ⇒ HtmlValidator
constructor
A new instance of HtmlValidator.
- #invalid? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(govspeak_string, options = {}) ⇒ HtmlValidator
Returns a new instance of HtmlValidator.
4 5 6 7 |
# File 'lib/govspeak/html_validator.rb', line 4 def initialize(govspeak_string, = {}) @govspeak_string = govspeak_string.dup.force_encoding(Encoding::UTF_8) @allowed_image_hosts = [:allowed_image_hosts] end |
Instance Attribute Details
#govspeak_string ⇒ Object (readonly)
Returns the value of attribute govspeak_string.
2 3 4 |
# File 'lib/govspeak/html_validator.rb', line 2 def govspeak_string @govspeak_string end |
Instance Method Details
#invalid? ⇒ Boolean
9 10 11 |
# File 'lib/govspeak/html_validator.rb', line 9 def invalid? !valid? end |
#valid? ⇒ Boolean
13 14 15 16 17 |
# File 'lib/govspeak/html_validator.rb', line 13 def valid? dirty_html = govspeak_to_html(sanitize: false) clean_html = govspeak_to_html(sanitize: true) normalise_html(dirty_html) == normalise_html(clean_html) end |