Class: Article
- Inherits:
-
Object
- Object
- Article
- Defined in:
- lib/article.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#date ⇒ Object
Returns the value of attribute date.
-
#description ⇒ Object
Returns the value of attribute description.
-
#length ⇒ Object
Returns the value of attribute length.
-
#source ⇒ Object
Returns the value of attribute source.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(article_hash) ⇒ Article
constructor
A new instance of Article.
Constructor Details
#initialize(article_hash) ⇒ Article
Returns a new instance of Article.
8 9 10 11 |
# File 'lib/article.rb', line 8 def initialize(article_hash) article_hash.each {|key, value| self.send(("#{key}="), value)} @@all << self end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
4 5 6 |
# File 'lib/article.rb', line 4 def @author end |
#date ⇒ Object
Returns the value of attribute date.
4 5 6 |
# File 'lib/article.rb', line 4 def date @date end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/article.rb', line 4 def description @description end |
#length ⇒ Object
Returns the value of attribute length.
4 5 6 |
# File 'lib/article.rb', line 4 def length @length end |
#source ⇒ Object
Returns the value of attribute source.
4 5 6 |
# File 'lib/article.rb', line 4 def source @source end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/article.rb', line 4 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/article.rb', line 4 def url @url end |
Class Method Details
.all ⇒ Object
19 20 21 |
# File 'lib/article.rb', line 19 def self.all @@all end |
.create_from_collection(articles_array) ⇒ Object
13 14 15 16 17 |
# File 'lib/article.rb', line 13 def self.create_from_collection(articles_array) articles_array.each do |article_hash| Article.new(article_hash) end end |
.reset ⇒ Object
23 24 25 |
# File 'lib/article.rb', line 23 def self.reset @all.clear end |