Class: RpsRabGIT::RpsGame
- Inherits:
-
Object
- Object
- RpsRabGIT::RpsGame
- Defined in:
- lib/rps_rabGIT/rps_game.rb
Instance Method Summary collapse
-
#initialize ⇒ RpsGame
constructor
A new instance of RpsGame.
- #play ⇒ Object
Constructor Details
#initialize ⇒ RpsGame
Returns a new instance of RpsGame.
4 5 6 7 8 9 |
# File 'lib/rps_rabGIT/rps_game.rb', line 4 def initialize @play_options = ['R', 'P', 'S'] @win_combos = ['RS', 'SP', 'PR'] @player_choice = '' @comp_choice = '' end |
Instance Method Details
#play ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/rps_rabGIT/rps_game.rb', line 11 def play @comp_choice = @play_options.sample() prompt until valid_move? return 'Tie!' if @player_choice == @comp_choice return "Your #{@player_choice} beat computer's #{@comp_choice}" if win? "Computer's #{@comp_choice} beat your #{@player_choice}!" end |