class Standings::CLI
Public Instance Methods
record_user_selection_and_show_results!()
click to toggle source
# File lib/standings/cli.rb, line 3 def record_user_selection_and_show_results! league_selection = accept_input if league_selection handle_valid_league_selection(league_selection) else handle_help_message end end
Private Instance Methods
accept_input()
click to toggle source
# File lib/standings/cli.rb, line 15 def accept_input opts = Trollop::options do version <<-EOS ā½ Standings Version 1.0 | September 2016 Scott Luptowski | @scottluptowski EOS banner <<-EOS \nā½ Standings is a command line gem which lets users check the current standings in a number of European football/soccer leagues. Usage: \n EOS opt :epl, "š¬š§ English Premier League", short: :e opt :championship, "š¬š§ English Championship", short: :c opt :league1, "š¬š§ English League One", short: :o opt :league2, "š¬š§ English League Two", short: :t opt :spl, "š¬š§ Scottish Premiership", short: :s opt :liga, "šŖšø La Liga", short: :l opt :ligue, "š«š· Ligue 1", short: :f opt :seriea, "š®š¹ Seria A", short: :i opt :bundesliga, "š©šŖ Bundesliga", short: :d end opts.keys.detect { |k| opts[k] } end
handle_failure()
click to toggle source
# File lib/standings/cli.rb, line 54 def handle_failure puts "ā½ There was an error retrieving the scores!" end
handle_help_message()
click to toggle source
# File lib/standings/cli.rb, line 50 def handle_help_message puts "ā½ Standings requires you to pass in the flag of a league. Run with --help for help." end
handle_valid_league_selection(league_selection)
click to toggle source
# File lib/standings/cli.rb, line 41 def handle_valid_league_selection(league_selection) begin results = TableFetcher.new(league_selection).call Displayer.new(results).display_table rescue TableFetcher::FetchError, TableFetcher::ParseError handle_failure end end