Class: CLI
- Inherits:
-
Object
- Object
- CLI
- Defined in:
- lib/redbull_team/cli.rb
Instance Method Summary collapse
-
#ask_for_input ⇒ Object
binding.pry.
- #call ⇒ Object
- #check_for_input ⇒ Object
- #goodbye ⇒ Object
- #list_name ⇒ Object
- #more_info ⇒ Object
- #welcome ⇒ Object
Instance Method Details
#ask_for_input ⇒ Object
binding.pry
20 21 22 23 24 25 |
# File 'lib/redbull_team/cli.rb', line 20 def ask_for_input puts "\nPlease select between 1 and #{Player.all.length}" puts "To quit, type 'exit'." @input = gets.downcase.strip @input == 'exit' ? goodbye : check_for_input end |
#call ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/redbull_team/cli.rb', line 2 def call welcome list_name puts "\nWich player would you like to know more about" ask_for_input until @input == "exit" more_info ask_for_input end end |
#check_for_input ⇒ Object
30 31 32 33 34 35 |
# File 'lib/redbull_team/cli.rb', line 30 def check_for_input until @input.match(/^(\d)+$/) && @input.to_i.between?(0, Player.all.length) && @input != 'exit' puts "\nThe input you have typed is not a number within range" ask_for_input end end |
#goodbye ⇒ Object
26 27 28 29 |
# File 'lib/redbull_team/cli.rb', line 26 def goodbye puts "Thanks for visiting the NYC Redbull Soccer team" exit end |
#list_name ⇒ Object
15 16 17 18 19 |
# File 'lib/redbull_team/cli.rb', line 15 def list_name Scraper.new.make_player Player.all.each_with_index{|player, i| puts "#{i+1}. #{player.name}"} #binding.pry end |
#more_info ⇒ Object
36 37 38 39 |
# File 'lib/redbull_team/cli.rb', line 36 def more_info player = Player.all[@input.to_i - 1] puts "Player info is as follows:\n Position: #{player.position}\n Age: #{player.age}\n Height: #{player.height}" end |
#welcome ⇒ Object
12 13 14 |
# File 'lib/redbull_team/cli.rb', line 12 def welcome puts "Welcome to version 1 of the Redbull Team line up!" end |