Class: DeveloperNewsCliApp::Article
- Inherits:
-
Object
- Object
- DeveloperNewsCliApp::Article
- Defined in:
- lib/developer_news_cli_app/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.
-
#read_time ⇒ Object
Returns the value of attribute read_time.
-
#subtitle ⇒ Object
Returns the value of attribute subtitle.
-
#title ⇒ Object
Returns the value of attribute title.
-
#trailing ⇒ Object
Returns the value of attribute trailing.
-
#url ⇒ Object
Returns the value of attribute url.
-
#website ⇒ Object
Returns the value of attribute website.
Class Method Summary collapse
- .add_to_current_artciles(articles) ⇒ Object
- .all ⇒ Object
- .clear_current_articles ⇒ Object
- .current_articles ⇒ Object
- .display_articles(site) ⇒ Object
- .display_top_three(website) ⇒ Object
- .print_titles ⇒ Object
- .website(website) ⇒ Object
Instance Method Summary collapse
-
#initialize(title = nil, author = nil, date = nil, read_time = nil, url = nil, website = nil, subtile = nil, trailing = nil) ⇒ Article
constructor
A new instance of Article.
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, = nil, date = nil, read_time = nil, url = nil, website = nil, subtile = nil, trailing = nil) @title = title @author = @date = date @read_time = read_time @url = url @website = website @subtitle = subtile @trailing = trailing @@all << self end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
2 3 4 |
# File 'lib/developer_news_cli_app/article.rb', line 2 def @author end |
#date ⇒ Object
Returns the value of attribute date.
2 3 4 |
# File 'lib/developer_news_cli_app/article.rb', line 2 def date @date end |
#read_time ⇒ Object
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 |
#subtitle ⇒ Object
Returns the value of attribute subtitle.
2 3 4 |
# File 'lib/developer_news_cli_app/article.rb', line 2 def subtitle @subtitle end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/developer_news_cli_app/article.rb', line 2 def title @title end |
#trailing ⇒ Object
Returns the value of attribute trailing.
2 3 4 |
# File 'lib/developer_news_cli_app/article.rb', line 2 def trailing @trailing end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/developer_news_cli_app/article.rb', line 2 def url @url end |
#website ⇒ Object
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 |
.all ⇒ Object
18 19 20 |
# File 'lib/developer_news_cli_app/article.rb', line 18 def self.all @@all end |
.clear_current_articles ⇒ Object
26 27 28 |
# File 'lib/developer_news_cli_app/article.rb', line 26 def self.clear_current_articles @@current_articles.clear end |
.current_articles ⇒ Object
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 |
.print_titles ⇒ Object
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 |