Class: TildeScraper::Topic
- Inherits:
-
Object
- Object
- TildeScraper::Topic
- Extended by:
- Memorable::ClassMethods
- Includes:
- Memorable::InstanceMethods
- Defined in:
- lib/tilde_scraper/topic/topic.rb
Defined Under Namespace
Classes: TopicError
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#age ⇒ Object
Returns the value of attribute age.
-
#comment_count ⇒ Object
Returns the value of attribute comment_count.
-
#comment_link ⇒ Object
Returns the value of attribute comment_link.
-
#group ⇒ Object
Returns the value of attribute group.
-
#page_id ⇒ Object
Returns the value of attribute page_id.
-
#title ⇒ Object
Returns the value of attribute title.
-
#votes ⇒ Object
Returns the value of attribute votes.
-
#word_count ⇒ Object
Returns the value of attribute word_count.
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Memorable::ClassMethods
Methods included from Memorable::InstanceMethods
Instance Attribute Details
#age ⇒ Object
Returns the value of attribute age.
2 3 4 |
# File 'lib/tilde_scraper/topic/topic.rb', line 2 def age @age end |
#comment_count ⇒ Object
Returns the value of attribute comment_count.
2 3 4 |
# File 'lib/tilde_scraper/topic/topic.rb', line 2 def comment_count @comment_count end |
#comment_link ⇒ Object
Returns the value of attribute comment_link.
2 3 4 |
# File 'lib/tilde_scraper/topic/topic.rb', line 2 def comment_link @comment_link end |
#group ⇒ Object
Returns the value of attribute group.
2 3 4 |
# File 'lib/tilde_scraper/topic/topic.rb', line 2 def group @group end |
#page_id ⇒ Object
Returns the value of attribute page_id.
2 3 4 |
# File 'lib/tilde_scraper/topic/topic.rb', line 2 def page_id @page_id end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/tilde_scraper/topic/topic.rb', line 2 def title @title end |
#votes ⇒ Object
Returns the value of attribute votes.
2 3 4 |
# File 'lib/tilde_scraper/topic/topic.rb', line 2 def votes @votes end |
#word_count ⇒ Object
Returns the value of attribute word_count.
2 3 4 |
# File 'lib/tilde_scraper/topic/topic.rb', line 2 def word_count @word_count end |
Class Method Details
.all ⇒ Object
13 14 15 |
# File 'lib/tilde_scraper/topic/topic.rb', line 13 def self.all @@all end |
.create_from_array(array) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# 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) ⇒ Object
9 10 11 |
# File 'lib/tilde_scraper/topic/topic.rb', line 9 def self.find_by_page_id(id) all.select { |topic| topic.page_id == id } end |
Instance Method Details
#comments ⇒ Object
30 31 32 |
# File 'lib/tilde_scraper/topic/topic.rb', line 30 def comments TildeScraper::Comment.find_by_url(comment_link) end |
#display ⇒ Object
34 35 36 37 |
# File 'lib/tilde_scraper/topic/topic.rb', line 34 def display puts "#{title} Votes:#{votes}" puts "#{group} WC:#{word_count} #{age} #{comment_count}" end |