Module: Blog::ContentRules::Helpers
- Defined in:
- app/services/blog/content_rules.rb
Overview
Helpers for rule implementations — wraps Nokogiri parsing so each rule
doesn't repeat boilerplate.
Class Method Summary collapse
Class Method Details
.parse(html) ⇒ Object
95 96 97 98 99 100 101 |
# File 'app/services/blog/content_rules.rb', line 95 def parse(html) if defined?(Nokogiri::HTML5) Nokogiri::HTML5.fragment(html.to_s) else Nokogiri::HTML.fragment(html.to_s) end end |
.text_only(html) ⇒ Object
103 104 105 |
# File 'app/services/blog/content_rules.rb', line 103 def text_only(html) parse(html).text.gsub(/\s+/, ' ').strip end |