class Wikihow::Topic

Attributes

author[RW]
category[R]
intro[RW]
title[RW]
url[RW]

Public Class Methods

get_or_create_topics_from_category(category) click to toggle source
# File lib/wikihow/topic.rb, line 27
def self.get_or_create_topics_from_category(category)
  if category.topics == []
    Wikihow::Scraper.scrape_for_topics(category).each{|topic_hash|self.new(topic_hash, category)}
  end
  category.topics
end
new(topic_hash = nil, category = nil) click to toggle source
# File lib/wikihow/topic.rb, line 4
def initialize(topic_hash = nil, category = nil)
  self.title = topic_hash[:title] if topic_hash != nil
  self.url = topic_hash[:url] if topic_hash != nil
  self.category = category if category != nil
  self.sections = []
end

Public Instance Methods

category=(category) click to toggle source
# File lib/wikihow/topic.rb, line 11
def category=(category)
  @category = category
  category.add_topic(self)
end
sections() click to toggle source
# File lib/wikihow/topic.rb, line 16
def sections
  if @sections == []
    @sections = Wikihow::Scraper.scrape_topic(self)
  end
  @sections
end
sections=(sections) click to toggle source
# File lib/wikihow/topic.rb, line 23
def sections=(sections)
  @sections = sections
end