class DeveloperNewsCliApp::Article
Attributes
date[RW]
read_time[RW]
subtitle[RW]
title[RW]
trailing[RW]
url[RW]
website[RW]
Public Class Methods
add_to_current_artciles(articles)
click to toggle source
# File lib/developer_news_cli_app/article.rb, line 30 def self.add_to_current_artciles(articles) self.current_articles << articles end
all()
click to toggle source
# File lib/developer_news_cli_app/article.rb, line 18 def self.all @@all end
clear_current_articles()
click to toggle source
# File lib/developer_news_cli_app/article.rb, line 26 def self.clear_current_articles @@current_articles.clear end
current_articles()
click to toggle source
# File lib/developer_news_cli_app/article.rb, line 22 def self.current_articles @@current_articles end
display_articles(site)
click to toggle source
# 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)
click to toggle source
# 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
new(title = nil, author = nil, date = nil, read_time = nil, url = nil, website = nil, subtile = nil, trailing = nil)
click to toggle source
# 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
print_titles()
click to toggle source
# 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)
click to toggle source
# 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