Guest User

Untitled

a guest
Feb 21st, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. def self.select_by(sport)
  2. all.select do |object|
  3. ATTRIBUTES.any? { |attr| object.public_send(attr).include?(sport) }
  4. end
  5. end
  6.  
  7. def self.football
  8. select_by("Football")
  9. end
  10.  
  11. def self.baseball
  12. select_by("Baseball")
  13. end
  14.  
  15. def self.college_basketball
  16. select_by("College Basketball")
  17. end
  18.  
  19. def self.nba_basketball
  20. select_by("NBA")
  21. end
  22.  
  23. def user_input
  24.  
  25. input = nil
  26. input = gets.strip.downcase
  27.  
  28. case input
  29.  
  30. when "football"
  31. info = SportsToday::Schedule.football
  32. show_info(info)
  33.  
  34. when "baseball"
  35. info = SportsToday::Schedule.baseball
  36. show_info(info)
  37. post_search_options
  38.  
  39. when "college basketball"
  40. info = SportsToday::Schedule.college_basketball
  41. show_info(info)
  42. post_search_options
  43.  
  44.  
  45. when "nba basketball"
  46. info = SportsToday::Schedule.nba_basketball
  47. show_info(info)
  48. post_search_options
  49.  
  50. def show_info(info)
  51. info.collect {|info|
  52. puts""
  53. puts""
  54. puts "nEvent: #{info.sport}"
  55. puts "nTime: #{info.time}"
  56. puts "nDescription: #{info.description}"
  57. puts "nMatchup: #{info.matchup}"
  58. puts ""
  59. puts ""
  60. }
  61. end
Add Comment
Please, Sign In to add comment