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
# File 'lib/wiki_on_this_day/cli.rb', line 5

def initialize
  @todays_page = WikiOnThisDay::Scraper::Homepage.new
  @todays_page.summarize
  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



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

def more_information(year)
  self.todays_page.snippets.each do |snippet|
    if snippet.year == year
      puts ''
      puts snippet.article_abstract
      puts ''
    end
  end
end