class TruthOrDare
Constants
- ANSWERS
- DARES
- TRUTHS
Attributes
initial_choice[R]
Public Instance Methods
play()
click to toggle source
# File lib/truth_or_dare.rb, line 75 def play print_welcome get_user_choice if valid_user_input? get_challenge else print_bad_input_message play end end
Private Instance Methods
get_challenge()
click to toggle source
# File lib/truth_or_dare.rb, line 106 def get_challenge case initial_choice when 't' puts TRUTHS.sample truth = gets.chomp puts ANSWERS.sample when 'd' puts DARES.sample end end
get_user_choice()
click to toggle source
# File lib/truth_or_dare.rb, line 97 def get_user_choice @initial_choice = gets.chomp.downcase.strip end
print_bad_input_message()
click to toggle source
# File lib/truth_or_dare.rb, line 93 def print_bad_input_message print "Sorry, #{initial_choice} is not a valid choice. " end
print_welcome()
click to toggle source
# File lib/truth_or_dare.rb, line 89 def print_welcome print "Pick Truth or Dare (t/d): " end
valid_user_input?()
click to toggle source
# File lib/truth_or_dare.rb, line 101 def valid_user_input? initial_choice == 't' || initial_choice == 'd' end