module Planetruby2feed::Parser
Public Instance Methods
find_posts()
click to toggle source
# File lib/planetruby2feed/parser.rb, line 6 def find_posts @webpage.css('.main div.post', '.main div.star-post').each do |post| @posts << parse_post(post) end end
Private Instance Methods
parse_post(post)
click to toggle source
# File lib/planetruby2feed/parser.rb, line 14 def parse_post(post) begin title = post.css('> h2 a').text.strip link = post.css('> h2 a').attr('href').value star_post = (post.attr('class') == 'star-post') post.css('> h2').remove post.css('span.small-text').remove return { title: title, link: link, star_post: star_post, content: post.to_html } rescue nil end end