class TldrNews::Article

Attributes

contents[RW]
headline[RW]
time[RW]
url[RW]

Public Class Methods

all() click to toggle source
# File lib/tldr_news/article.rb, line 13
def self.all
  @@all
end
find(input) click to toggle source
# File lib/tldr_news/article.rb, line 26
def self.find(input)
  @@all[input.to_i - 1]
end
new(headline = nil, contents = nil, url = nil, time = nil) click to toggle source
# File lib/tldr_news/article.rb, line 5
def initialize(headline = nil, contents = nil, url = nil, time = nil)
  @url = url
  @contents = contents
  @headline = headline
  @time = time
  @@all << self
end
new_from_html(listing) click to toggle source
# File lib/tldr_news/article.rb, line 17
def self.new_from_html(listing)
  self.new(
  listing.css('h1.title').text,
  listing.css('div.summary').text,
  listing.css('a').attribute('href').value,
  listing.css('time').text
  )
end