class NytJourneys::CommandLineInterface

Attributes

input[RW]

Public Instance Methods

call() click to toggle source
# File lib/nyt_journeys/command_line_interface.rb, line 4
def call
  NytJourneys::Data_Generator.new.make_journeys
  greeting
  start
end
greeting() click to toggle source
# File lib/nyt_journeys/command_line_interface.rb, line 10
def greeting
  puts ""
  puts "~~*~~*~~*~~ New York Times Journeys ~~*~~*~~*~~"
  puts ""
  puts NytJourneys::Scraper.scrape_quotes.sample
  puts ""
end
list_journeys() click to toggle source
# File lib/nyt_journeys/command_line_interface.rb, line 18
def list_journeys
  puts ""
  puts "~~*~~*~~*~~ Available New York Times Journeys ~~*~~*~~*~~"
  puts ""
  NytJourneys::Journeys.all.each.with_index(1) do |journey, index|
    puts "#{index}. #{journey.name}"
  end
  puts ""
end
list_types() click to toggle source
# File lib/nyt_journeys/command_line_interface.rb, line 64
def list_types
  puts ""
  puts "~~*~~*~~*~~ Journeys Focused On ~~*~~*~~*~~"
  puts ""
  NytJourneys::Journeys.types.each.with_index(1) do |type, index|
    puts "#{index}. #{type}"
  end
  puts ""
end
navigate_category(category) click to toggle source
navigate_journeys() click to toggle source
navigate_types() click to toggle source
print_category(category) click to toggle source
print_journey(journey) click to toggle source
start() click to toggle source
# File lib/nyt_journeys/command_line_interface.rb, line 121
def start
  self.input = nil
  while self.input != "exit"
    puts ""
    puts "Enter 'list' to see all journeys."
    puts "Enter 'types' to see journey categories."
    puts "Enter 'exit' to end the program."
    puts ""
    self.input = gets.downcase.strip
    if self.input == "list"
      navigate_journeys
    elsif self.input == "types"
      navigate_types
    end
  end
  puts ""
  puts NytJourneys::Scraper.scrape_quotes.sample
  puts ""
  puts "Enjoy the journey!"
end