class Partyhat::Forums::ForumThread
TODO: Add pagination support
e.g. thread.next_page
Constants
- URL_FORMAT
Public Class Methods
new(qfc)
click to toggle source
# File lib/partyhat/forums/forum_thread.rb, line 11 def initialize qfc raise InvalidArgumentError('Invalid quick find code') unless Forums.valid_qfc?(qfc) @posts = [] @qfc = qfc @link = URL_FORMAT % qfc.gsub(/-/, ",") parse_from_page Partyhat::Util.fetch_remote(@link) end
Public Instance Methods
link()
click to toggle source
# File lib/partyhat/forums/forum_thread.rb, line 27 def link @link end
posts()
click to toggle source
# File lib/partyhat/forums/forum_thread.rb, line 23 def posts @posts end
qfc()
click to toggle source
# File lib/partyhat/forums/forum_thread.rb, line 31 def qfc @qfc end
title()
click to toggle source
# File lib/partyhat/forums/forum_thread.rb, line 19 def title @title end
Protected Instance Methods
parse_from_page(page)
click to toggle source
# File lib/partyhat/forums/forum_thread.rb, line 36 def parse_from_page page document = Nokogiri::HTML(page) # Get title @title = document.css('.BarFullTop span.G0').first.content # Get posts on the page document.css('#MainContent .message').each do |post| author, posted, contents = [post.css('.author'), post.css('.BubbleCreation span'), post.css('.msgcontents td')].map(&:text) @posts << Partyhat::Forums::ForumPost.new(author, posted, contents) end end