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.
-
#content ⇒ Object
Returns the value of attribute content.
-
#subtitle ⇒ Object
Returns the value of attribute subtitle.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Article
constructor
A new instance of Article.
Constructor Details
#initialize ⇒ Article
Returns a new instance of Article.
5 6 7 |
# File 'lib/article.rb', line 5 def initialize @@all << self end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
2 3 4 |
# File 'lib/article.rb', line 2 def end |
#content ⇒ Object
Returns the value of attribute content.
2 3 4 |
# File 'lib/article.rb', line 2 def content @content end |
#subtitle ⇒ Object
Returns the value of attribute subtitle.
2 3 4 |
# File 'lib/article.rb', line 2 def subtitle @subtitle end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/article.rb', line 2 def title @title end |
Class Method Details
.all ⇒ Object
18 19 20 |
# File 'lib/article.rb', line 18 def self.all @@all end |
.new_from_hash(hash) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/article.rb', line 9 def self.new_from_hash(hash) article = Article.new hash.each do |attribute, value| article.send("#{attribute}=", value) end article.content = article.content.reject {|para| para.text==""} end |
.reset_all ⇒ Object
22 23 24 |
# File 'lib/article.rb', line 22 def self.reset_all @@all = [] end |