class BbcNewsCliGem::Article
Attributes
intro[RW]
link[R]
title[R]
web_page[R]
Public Class Methods
new(web_page, title, link)
click to toggle source
# File lib/bbc_news_cli_gem/article.rb, line 6 def initialize(web_page, title, link) @title = title @link = link @web_page = web_page add_to_web_page(web_page) if valid_title_and_link self end
Public Instance Methods
add_to_web_page(web_page)
click to toggle source
# File lib/bbc_news_cli_gem/article.rb, line 22 def add_to_web_page(web_page) web_page.articles << self @web_page = web_page end
display()
click to toggle source
# File lib/bbc_news_cli_gem/article.rb, line 27 def display intro ? intro : get_intro puts "*****************************************************************" puts "TITLE: #{title}" puts "-----------------------------------------------------------------" puts "INTRO: #{intro}" puts "*****************************************************************" end
open()
click to toggle source
# File lib/bbc_news_cli_gem/article.rb, line 36 def open Launchy.open("#{BbcNewsCliGem::RootAddress + self.link}") end
uniq_title()
click to toggle source
# File lib/bbc_news_cli_gem/article.rb, line 14 def uniq_title !web_page.articles.find { | article | article.title == title } end
valid_title_and_link()
click to toggle source
# File lib/bbc_news_cli_gem/article.rb, line 18 def valid_title_and_link title && title != "" && link && link != "" && uniq_title end
Private Instance Methods
get_intro()
click to toggle source
# File lib/bbc_news_cli_gem/article.rb, line 42 def get_intro article_page = BbcNewsCliGem::Scraper.new(BbcNewsCliGem::RootAddress+link) self.intro = article_page.scrape_intro end