class NewsReaderCli::Article
Attributes
content[RW]
description[RW]
publishedAt[RW]
source[RW]
title[RW]
url[RW]
urltoimage[RW]
Public Class Methods
all()
click to toggle source
# File lib/news_reader_cli/article.rb, line 13 def self.all @@all end
find_article_by_article_index(number)
click to toggle source
find the article instance by article index number
# File lib/news_reader_cli/article.rb, line 25 def self.find_article_by_article_index(number) self.all[number - 1] end
find_url_by_article_index(number)
click to toggle source
find an article's URL by using iterations
# File lib/news_reader_cli/article.rb, line 31 def self.find_url_by_article_index(number) self.all.find.with_index(1) do |article, index| index == number end.url end
list_all_titles()
click to toggle source
list all the articlels titles (in alphabat )
# File lib/news_reader_cli/article.rb, line 18 def self.list_all_titles self.all.collect.with_index(1) do |article, index| "#{index}. #{article.title}" end end
new(article_hash)
click to toggle source
# File lib/news_reader_cli/article.rb, line 6 def initialize(article_hash) article_hash.each do |method, article_data| self.send("#{method}=", article_data) if self.respond_to?("#{method}=") end @@all << self end