Class: NbaLeader::CLI
- Inherits:
-
Object
- Object
- NbaLeader::CLI
- Defined in:
- lib/nba_leader/cli.rb
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
3 4 5 6 7 |
# File 'lib/nba_leader/cli.rb', line 3 def call list_leaders goodbye end |
#goodbye ⇒ Object
37 38 39 |
# File 'lib/nba_leader/cli.rb', line 37 def goodbye puts "Thanks for stopping by. Now go score buckets!!".yellow end |
#list_leaders ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/nba_leader/cli.rb', line 9 def list_leaders puts "Here are the NBA All-Time Leading Scorers:" @leaders = NbaLeader::Leader.scrape_leaders @leaders.each.with_index(1) do |leader, i| puts "#{i}. #{leader.name}" end end |
#menu ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/nba_leader/cli.rb', line 17 def input = nil while input != "exit" puts "Enter the number of the scoring leader you'd like more info on. Type list to see leaders again or type exit..." input = gets.strip.downcase if input.to_i > 0 && input.to_i < 6 the_leader = @leaders[input.to_i-1] puts "#{the_leader.name} - #{the_leader.points}".red elsif input == "list" list_leaders else unless input == "exit" puts "Invalid selection. Please type list or exit".bold end end end end |