Class: DeveloperNewsCliApp::Article

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title = nil, author = nil, date = nil, read_time = nil, url = nil, website = nil, subtile = nil, trailing = nil) ⇒ Article

Returns a new instance of Article.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/developer_news_cli_app/article.rb', line 6

def initialize(title = nil, author = nil, date = nil, read_time = nil, url = nil, website = nil, subtile = nil, trailing = nil)
	@title = title
	@author = author
	@date = date
	@read_time = read_time
	@url = url
	@website = website
	@subtitle = subtile
	@trailing = trailing
	@@all << self
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



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

def author
  @author
end

#dateObject

Returns the value of attribute date.



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

def date
  @date
end

#read_timeObject

Returns the value of attribute read_time.



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

def read_time
  @read_time
end

#subtitleObject

Returns the value of attribute subtitle.



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

def subtitle
  @subtitle
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#trailingObject

Returns the value of attribute trailing.



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

def trailing
  @trailing
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

#websiteObject

Returns the value of attribute website.



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

def website
  @website
end

Class Method Details

.add_to_current_artciles(articles) ⇒ Object



30
31
32
# File 'lib/developer_news_cli_app/article.rb', line 30

def self.add_to_current_artciles(articles)
	self.current_articles << articles
end

.allObject



18
19
20
# File 'lib/developer_news_cli_app/article.rb', line 18

def self.all
	@@all
end

.clear_current_articlesObject



26
27
28
# File 'lib/developer_news_cli_app/article.rb', line 26

def self.clear_current_articles
	@@current_articles.clear
end

.current_articlesObject



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

def self.current_articles
	@@current_articles
end

.display_articles(site) ⇒ Object



53
54
55
56
57
58
# File 'lib/developer_news_cli_app/article.rb', line 53

def self.display_articles(site)
	puts "#{site}:\n"
	self.website(site)[0..9].each.with_index(1) do |article, index|
		puts "  #{index}. #{article.title}"
	end
end

.display_top_three(website) ⇒ Object



47
48
49
50
51
# File 'lib/developer_news_cli_app/article.rb', line 47

def self.display_top_three(website)
	self.website(website)[0..2].each.with_index(1) do |article, index|
		puts "  #{index}. #{article.title}"
	end
end


34
35
36
37
38
# File 'lib/developer_news_cli_app/article.rb', line 34

def self.print_titles
	self.all.each do |article|
		puts "#{article.title}"
	end
end

.website(website) ⇒ Object



40
41
42
43
44
45
# File 'lib/developer_news_cli_app/article.rb', line 40

def self.website(website)
	self.all.collect do |article|
		if article.website == website
		end
	end
end