class TildeScraper::Page
Attributes
group[RW]
next_link[RW]
order[RW]
page_id[RW]
period[RW]
prev_link[RW]
url[RW]
Public Class Methods
all()
click to toggle source
# File lib/tilde_scraper/page.rb, line 9 def self.all @@all end
new(attributes)
click to toggle source
Calls superclass method
TildeScraper::Memorable::InstanceMethods::new
# File lib/tilde_scraper/page.rb, line 13 def initialize(attributes) super(attributes) get_query end
Public Instance Methods
display()
click to toggle source
# File lib/tilde_scraper/page.rb, line 22 def display topics.each.with_index(1) do |topic, index| puts "#{index}. #{topic.type}post" topic.display puts "" end end
topics()
click to toggle source
# File lib/tilde_scraper/page.rb, line 18 def topics TildeScraper::Topic.find_by_page_id(page_id) end
Private Instance Methods
get_query()
click to toggle source
# File lib/tilde_scraper/page.rb, line 31 def get_query url_array = url.split("?") query_hash = {order: "Activity", period: "All Time"} group = url.scan(/~\w*/) query_hash[:group] = group.length == 1 ? group.first : nil if url_array.length == 2 query_hash = url_array[1].split("&").reduce(query_hash) do |hash, var| var = var.split("=") hash[var[0].to_sym] = var[1] unless var[0] == "before" || var[0] == "after" hash end end add_attributes(query_hash) end