Class: HtmlToTextConverter
- Inherits:
-
Object
- Object
- HtmlToTextConverter
- Defined in:
- lib/rallycat/html_to_text_converter.rb
Instance Method Summary collapse
-
#initialize(html_string) ⇒ HtmlToTextConverter
constructor
A new instance of HtmlToTextConverter.
- #parse ⇒ Object
Constructor Details
#initialize(html_string) ⇒ HtmlToTextConverter
Returns a new instance of HtmlToTextConverter.
5 6 7 |
# File 'lib/rallycat/html_to_text_converter.rb', line 5 def initialize(html_string) @html_string = html_string end |
Instance Method Details
#parse ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rallycat/html_to_text_converter.rb', line 9 def parse return '' unless @html_string html = pre_parse @fragment = Nokogiri::HTML.fragment(html) add_newline_after_block_elements parse_whitespace parse_lists @fragment.content end |