class NewsReader::Article
Attributes
date[RW]
text[RW]
title[RW]
url[RW]
Public Class Methods
all()
click to toggle source
# File lib/news_reader/article.rb, line 57 def self.all @@all end
import(collection)
click to toggle source
# File lib/news_reader/article.rb, line 18 def self.import collection collection.each do |article| NewsReader::Article.new article end end
list()
click to toggle source
# File lib/news_reader/article.rb, line 24 def self.list puts "--------- Blog Articles ---------" @@all.each.with_index(1) do |article, index| puts " - #{index}. #{article.title}" end end
new(article)
click to toggle source
# File lib/news_reader/article.rb, line 5 def initialize article article.each do |key, value| self.send("#{key}=", value) end @@all << self end
read()
click to toggle source
# File lib/news_reader/article.rb, line 31 def self.read self.list self.menu input = nil while input != "menu" input = gets.strip index = input.to_i - 1 if !index.between?(0, self.all.size - 1) puts "(-_-) You must choose an article that exists in our database" else article = self.all[index] puts "------ #{article.title} ------" puts "-- Date Published: #{article.date}" puts "-- Article Text: #{article.text}" puts "-- Ctr/Alt + click http://www.loremipsum.biz/blog#{article.url} to go to the article page." puts "------ ------ ------ ------ ------" self.menu end end end
Public Instance Methods
add_attributes(attributes)
click to toggle source
# File lib/news_reader/article.rb, line 12 def add_attributes attributes attributes.each do |key, value| self.send("#{key}=", value) end end