Class: NtrResults::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/ntr_results/cli.rb

Overview

controller cli

Instance Method Summary collapse

Instance Method Details

#callObject



6
7
8
9
10
11
# File 'lib/ntr_results/cli.rb', line 6

def call
  list_events
  menu
  # turbo_encabulator

end

#list_eventsObject



13
14
15
16
17
18
19
20
# File 'lib/ntr_results/cli.rb', line 13

def list_events
  puts "----------National Team Roping Results:----------"
  puts " "
  @events = NtrResults::Scraper.all
  @events.each.with_index(1) do |event, i|
    puts "#{i}. #{event.name} - #{event.date} - #{event.location}"
  end
end


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ntr_results/cli.rb', line 22

def menu
  input = nil
  while input != 'exit'
    puts " "
    puts "Enter the number of the event you'd like to know the winners of"
    puts "or type 'list' to view the events again or type 'exit' to exit"
    input = gets.strip.downcase

    if (input.to_i > 0) && (input.to_i < 4)
      main_event = @events[input.to_i-1]
      puts "#{main_event.name} - #{main_event.winner}"
    elsif input == "list"
      list_events
    elsif input == "exit"
      turbo_encabulator
    elsif input.to_i >= 3
      sleep 0.33
      puts "I'm sorry. There are only 3 events."
      sleep 1.0
    else
      puts " "
      puts "I'm sorry. I don't understand what you want."
      puts " "
    end
  end
end

#turbo_encabulatorObject



49
50
51
52
53
# File 'lib/ntr_results/cli.rb', line 49

def turbo_encabulator
  puts " "
  puts "Check back next week for more NTR results"
  puts " "
end