Class: HtmlParser
- Inherits:
-
Object
- Object
- HtmlParser
- Defined in:
- lib/html_parser.rb
Instance Attribute Summary collapse
-
#descriptions ⇒ Object
Returns the value of attribute descriptions.
-
#doc ⇒ Object
Returns the value of attribute doc.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#summaries ⇒ Object
Returns the value of attribute summaries.
-
#titles ⇒ Object
Returns the value of attribute titles.
Instance Method Summary collapse
-
#initialize(html) ⇒ HtmlParser
constructor
A new instance of HtmlParser.
- #parse ⇒ Object
Constructor Details
#initialize(html) ⇒ HtmlParser
Returns a new instance of HtmlParser.
8 9 10 |
# File 'lib/html_parser.rb', line 8 def initialize(html) @doc = Nokogiri::HTML.parse(html) end |
Instance Attribute Details
#descriptions ⇒ Object
Returns the value of attribute descriptions.
6 7 8 |
# File 'lib/html_parser.rb', line 6 def descriptions @descriptions end |
#doc ⇒ Object
Returns the value of attribute doc.
6 7 8 |
# File 'lib/html_parser.rb', line 6 def doc @doc end |
#metadata ⇒ Object
Returns the value of attribute metadata.
6 7 8 |
# File 'lib/html_parser.rb', line 6 def @metadata end |
#summaries ⇒ Object
Returns the value of attribute summaries.
6 7 8 |
# File 'lib/html_parser.rb', line 6 def summaries @summaries end |
#titles ⇒ Object
Returns the value of attribute titles.
6 7 8 |
# File 'lib/html_parser.rb', line 6 def titles @titles end |
Instance Method Details
#parse ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/html_parser.rb', line 12 def parse @titles = @doc.css('dt > h3') @metadata = @doc.css('ul.entry-metadata > li.entry-type > span') @summaries = @doc.css('div.entry-summary > p') @descriptions = @doc.css('div.entry-document') clean_string end |