class TildeScraper::Topic

Attributes

age[RW]
comment_count[RW]
group[RW]
page_id[RW]
title[RW]
votes[RW]
word_count[RW]

Public Class Methods

all() click to toggle source
# File lib/tilde_scraper/topic/topic.rb, line 13
def self.all
  @@all
end
create_from_array(array) click to toggle source
# File lib/tilde_scraper/topic/topic.rb, line 17
def self.create_from_array(array)
  array.each do |attributes|
    if attributes.keys.include?(:topic_text)
      TildeScraper::TextTopic.create(attributes)
    elsif attributes.keys.include?(:link)
      TildeScraper::LinkTopic.create(attributes)
    else
      binding.pry
      raise TopicError
    end
  end
end
find_by_page_id(id) click to toggle source
# File lib/tilde_scraper/topic/topic.rb, line 9
def self.find_by_page_id(id)
  all.select { |topic| topic.page_id == id }
end

Public Instance Methods

comments() click to toggle source
# File lib/tilde_scraper/topic/topic.rb, line 30
def comments
  TildeScraper::Comment.find_by_url(comment_link)
end
display() click to toggle source
# File lib/tilde_scraper/topic/topic.rb, line 34
def display
  puts "#{title} Votes:#{votes}"
  puts "#{group} WC:#{word_count} #{age} #{comment_count}"
end