Class: GoodNews::Topic

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

Constant Summary collapse

@@all =

Class variable stores all topics objects.

[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTopic

Instantiates with an article attribute to store all articles of the topic.



8
9
10
# File 'lib/good_news/topic.rb', line 8

def initialize
    @articles = []
end

Instance Attribute Details

#articlesObject

Returns the value of attribute articles.



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

def articles
  @articles
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#web_addrObject

Returns the value of attribute web_addr.



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

def web_addr
  @web_addr
end

Class Method Details

.allObject

Class method to get all topics.



13
14
15
# File 'lib/good_news/topic.rb', line 13

def self.all
    @@all
end

Instance Method Details

#saveObject

Method to save topic object into @@all.



18
19
20
# File 'lib/good_news/topic.rb', line 18

def save
    @@all << self
end