Class: Wfstatus::Parser
- Inherits:
-
Object
- Object
- Wfstatus::Parser
- Defined in:
- lib/wfstatus/parser.rb
Instance Attribute Summary collapse
-
#html ⇒ Object
readonly
Returns the value of attribute html.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
-
#initialize(html, config) ⇒ Parser
constructor
A new instance of Parser.
- #messages ⇒ Object
- #parse ⇒ Object
- #posts ⇒ Object
Constructor Details
#initialize(html, config) ⇒ Parser
Returns a new instance of Parser.
6 7 8 9 10 |
# File 'lib/wfstatus/parser.rb', line 6 def initialize(html, config) @html = html @config = config @page = Nokogiri::HTML(@html) end |
Instance Attribute Details
#html ⇒ Object (readonly)
Returns the value of attribute html.
5 6 7 |
# File 'lib/wfstatus/parser.rb', line 5 def html @html end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
5 6 7 |
# File 'lib/wfstatus/parser.rb', line 5 def page @page end |
Instance Method Details
#messages ⇒ Object
12 13 14 |
# File 'lib/wfstatus/parser.rb', line 12 def ||= parse end |
#parse ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/wfstatus/parser.rb', line 16 def parse = [] posts.each do |p| posted = p.at_css('div.entry-date abbr').attributes['title'] = p.at_css('div.entry-content').text title_link = p.at_css('.entry-title a') url = title_link.attributes['href'] title = title_link.text << .new(posted, title, , url, @config) end end |
#posts ⇒ Object
29 30 31 |
# File 'lib/wfstatus/parser.rb', line 29 def posts @posts ||= @page.css('div.post') end |