class Marvel101::CLI
Constants
- LINE_LEN
- SOURCE
- STARTING_PAGES
Public Instance Methods
call()
click to toggle source
# File lib/marvel_101/cli.rb, line 15 def call puts "\nWelcome to Marvel 101!" main_menu end
display_main()
click to toggle source
# File lib/marvel_101/cli.rb, line 54 def display_main puts "\n" + "-" * LINE_LEN puts "Here are your primary options:" STARTING_PAGES.each.with_index(1) {|page, idx| puts "#{idx}. #{page[0]}!"} puts "-" * LINE_LEN puts "You can also enter (E)xit to... exit" puts "Select a number from the options above and we'll get started!" end
display_topic(topic)
click to toggle source
# File lib/marvel_101/cli.rb, line 63 def display_topic(topic) break_len = (LINE_LEN - topic.name.size) / 2.0 puts "\n" + "-" * break_len.floor + "#{topic.name}" + "-" * break_len.ceil topic.display puts "-" * LINE_LEN options_message(topic) end
error(topic)
click to toggle source
# File lib/marvel_101/cli.rb, line 87 def error(topic) puts "\nSorry, that wasn't a valid option. Let's try again." topic == "main" ? main_menu : topic_menu(topic) end
exit_message()
click to toggle source
# File lib/marvel_101/cli.rb, line 76 def exit_message puts "\nOh ok, well have a super day!" end
open_link(url, topic)
click to toggle source
# File lib/marvel_101/cli.rb, line 71 def open_link(url, topic) Launchy.open(topic.urls[url]) if topic.urls.include?(url) topic_menu(topic) end
options_message(topic)
click to toggle source
# File lib/marvel_101/cli.rb, line 80 def options_message(topic) puts "Enter an option number for more info!" if topic.takes_input? puts "You can enter (M)ain to go back to the main menu or (E)xit to... exit" puts "Type (L)ist to return to #{topic.list.name} menu" if !topic.list? puts "Type (T)eam to return to #{topic.team.name} menu" if topic.has_team? end