Class: Wikihow::Topic
- Inherits:
-
Object
- Object
- Wikihow::Topic
- Defined in:
- lib/wikihow/topic.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
TODO.
-
#category ⇒ Object
Returns the value of attribute category.
-
#intro ⇒ Object
TODO.
-
#title ⇒ Object
TODO.
-
#url ⇒ Object
TODO.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(topic_hash = nil, category = nil) ⇒ Topic
constructor
A new instance of Topic.
- #sections ⇒ Object
- #sections=(sections) ⇒ Object
Constructor Details
#initialize(topic_hash = nil, category = nil) ⇒ Topic
Returns a new instance of Topic.
4 5 6 7 8 9 |
# 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 |
Instance Attribute Details
#author ⇒ Object
TODO
2 3 4 |
# File 'lib/wikihow/topic.rb', line 2 def @author end |
#category ⇒ Object
Returns the value of attribute category.
3 4 5 |
# File 'lib/wikihow/topic.rb', line 3 def category @category end |
#intro ⇒ Object
TODO
2 3 4 |
# File 'lib/wikihow/topic.rb', line 2 def intro @intro end |
#title ⇒ Object
TODO
2 3 4 |
# File 'lib/wikihow/topic.rb', line 2 def title @title end |
#url ⇒ Object
TODO
2 3 4 |
# File 'lib/wikihow/topic.rb', line 2 def url @url end |
Class Method Details
.get_or_create_topics_from_category(category) ⇒ Object
27 28 29 30 31 32 |
# 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 |
Instance Method Details
#sections ⇒ Object
16 17 18 19 20 21 |
# File 'lib/wikihow/topic.rb', line 16 def sections if @sections == [] @sections = Wikihow::Scraper.scrape_topic(self) end @sections end |
#sections=(sections) ⇒ Object
23 24 25 |
# File 'lib/wikihow/topic.rb', line 23 def sections=(sections) @sections = sections end |