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
print_category(category)
click to toggle source
# File lib/nyt_journeys/command_line_interface.rb, line 92 def print_category(category) puts "" puts "~~*~~*~~*~~ Journeys Focused On #{category} ~~*~~*~~*~~" puts "" NytJourneys::Journeys.find_by_type(category).each.with_index(1) do |journey, index| puts "#{index}. #{journey.name}" end puts "" end
print_journey(journey)
click to toggle source
# File lib/nyt_journeys/command_line_interface.rb, line 45 def print_journey(journey) puts "" puts "~~*~~*~~*~~ #{journey.name} ~~*~~*~~*~~" puts "A Journey Focused On #{journey.type}" puts "" puts journey.description puts "" puts "From: #{journey.cost}" puts "" puts "Journey Duration: #{journey.length}" puts "" puts "Available Dates:" puts journey.dates puts "" puts "Itinerary:" puts journey.itinerary puts "" end
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