Sha256: e46bb5924b6a00c6cf7d65bd162b68654665c51dfe1d27ee54f30da2ee7800fe

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

class DeveloperNewsCliApp::Article
	attr_accessor :title, :author, :date, :read_time, :url, :website, :subtitle, :trailing

	@@all = []

	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

	def self.all
		@@all
	end

	def self.current_articles
		@@current_articles
	end

	def self.clear_current_articles
		@@current_articles.clear
	end

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

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

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

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

	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

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
developer_news_cli_app-0.1.5 lib/developer_news_cli_app/article.rb
developer_news_cli_app-0.1.4 lib/developer_news_cli_app/article.rb
developer_news_cli_app-0.1.3 lib/developer_news_cli_app/article.rb
developer_news_cli_app-0.1.1 lib/developer_news_cli_app/article.rb
developer_news_cli_app-0.1.0 lib/developer_news_cli_app/article.rb