Class: WikiOnThisDay::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/wiki_on_this_day/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



5
6
7
8
9
10
11
12
# File 'lib/wiki_on_this_day/cli.rb', line 5

def initialize
  @todays_page = WikiOnThisDay::Scraper::Homepage.new
  print_controller = WikiOnThisDay::Printer.new(self.todays_page.html_doc, self.todays_page.on_this_day)
  print_controller.print
  print "To learn more about one of these events, enter the year as displayed above. To exit, enter anything else: "
  input = gets.strip
  more_information(input)
end

Instance Attribute Details

#todays_pageObject (readonly)

Returns the value of attribute todays_page.



3
4
5
# File 'lib/wiki_on_this_day/cli.rb', line 3

def todays_page
  @todays_page
end

Instance Method Details

#more_information(year) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/wiki_on_this_day/cli.rb', line 14

def more_information(year)
  self.todays_page.on_this_day.each do |key, value|
    if value[:year] == year
      puts ''
      puts WikiOnThisDay::Scraper::Article.new(value[:link_url]).article_abstract
      puts ''
    end
  end
end