Class: Article

Inherits:
Object
  • Object
show all
Defined in:
lib/article.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeArticle

Returns a new instance of Article.



5
6
7
# File 'lib/article.rb', line 5

def initialize
  @@all << self
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



2
3
4
# File 'lib/article.rb', line 2

def author
  @author
end

#contentObject

Returns the value of attribute content.



2
3
4
# File 'lib/article.rb', line 2

def content
  @content
end

#subtitleObject

Returns the value of attribute subtitle.



2
3
4
# File 'lib/article.rb', line 2

def subtitle
  @subtitle
end

#titleObject

Returns the value of attribute title.



2
3
4
# File 'lib/article.rb', line 2

def title
  @title
end

Class Method Details

.allObject



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_allObject



22
23
24
# File 'lib/article.rb', line 22

def self.reset_all
  @@all = []
end