Class: KdnuggetsRoundup::Article
- Inherits:
-
Object
- Object
- KdnuggetsRoundup::Article
- Defined in:
- lib/article.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#excerpt ⇒ Object
Returns the value of attribute excerpt.
-
#popular ⇒ Object
Returns the value of attribute popular.
-
#shared ⇒ Object
Returns the value of attribute shared.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #add_to_popular ⇒ Object
- #add_to_shared ⇒ Object
- #assign_attributes(attribute_hash) ⇒ Object
-
#initialize(title, url) ⇒ Article
constructor
A new instance of Article.
Constructor Details
#initialize(title, url) ⇒ Article
6 7 8 9 10 11 12 |
# File 'lib/article.rb', line 6 def initialize(title, url) @title = title @url = url @popular = false @shared = false @@all << self end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
3 4 5 |
# File 'lib/article.rb', line 3 def @author end |
#excerpt ⇒ Object
Returns the value of attribute excerpt.
3 4 5 |
# File 'lib/article.rb', line 3 def excerpt @excerpt end |
#popular ⇒ Object
Returns the value of attribute popular.
3 4 5 |
# File 'lib/article.rb', line 3 def popular @popular end |
#shared ⇒ Object
Returns the value of attribute shared.
3 4 5 |
# File 'lib/article.rb', line 3 def shared @shared end |
#summary ⇒ Object
Returns the value of attribute summary.
3 4 5 |
# File 'lib/article.rb', line 3 def summary @summary end |
#tags ⇒ Object
Returns the value of attribute tags.
3 4 5 |
# File 'lib/article.rb', line 3 def @tags end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/article.rb', line 3 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/article.rb', line 3 def url @url end |
Class Method Details
.all ⇒ Object
38 39 40 |
# File 'lib/article.rb', line 38 def self.all @@all end |
.find_by_title(title) ⇒ Object
18 19 20 |
# File 'lib/article.rb', line 18 def self.find_by_title(title) all.detect{|story| story.title == title} end |
.popular ⇒ Object
30 31 32 |
# File 'lib/article.rb', line 30 def self.popular all.select{|a| a.popular} end |
.shared ⇒ Object
34 35 36 |
# File 'lib/article.rb', line 34 def self.shared all.select{|a| a.shared} end |
Instance Method Details
#add_to_popular ⇒ Object
22 23 24 |
# File 'lib/article.rb', line 22 def add_to_popular @popular = true end |
#add_to_shared ⇒ Object
26 27 28 |
# File 'lib/article.rb', line 26 def add_to_shared @shared = true end |
#assign_attributes(attribute_hash) ⇒ Object
14 15 16 |
# File 'lib/article.rb', line 14 def assign_attributes(attribute_hash) attribute_hash.each{|k, v| self.send("#{k}=", v)} end |