Class: Player
- Inherits:
-
Object
- Object
- Player
- Defined in:
- lib/rps_telwell/player.rb
Overview
Create a new player, this will be the human-interaction portion.
Instance Attribute Summary collapse
-
#wins ⇒ Object
Instead of this could have another method which just increments wins.
Instance Method Summary collapse
-
#initialize ⇒ Player
constructor
Initialize, get number of wins.
-
#valid_move?(move) ⇒ Boolean
Validate move.
Constructor Details
#initialize ⇒ Player
Initialize, get number of wins
9 10 11 |
# File 'lib/rps_telwell/player.rb', line 9 def initialize @wins = 0 end |
Instance Attribute Details
#wins ⇒ Object
Instead of this could have another method which just increments wins
6 7 8 |
# File 'lib/rps_telwell/player.rb', line 6 def wins @wins end |
Instance Method Details
#valid_move?(move) ⇒ Boolean
Validate move
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rps_telwell/player.rb', line 14 def valid_move?(move) # Make sure input is an integer if move.class == Fixnum # Make sure move is 1-3 if (1..3).to_a.include?(move) true else false end else false end end |