Class: DsaCodebreakerGame::Gamer
- Inherits:
-
Object
- Object
- DsaCodebreakerGame::Gamer
- Defined in:
- lib/dsa_codebreaker_game/gamer.rb
Instance Attribute Summary collapse
-
#guess ⇒ Object
Returns the value of attribute guess.
-
#history ⇒ Object
Returns the value of attribute history.
-
#lives ⇒ Object
Returns the value of attribute lives.
Instance Method Summary collapse
- #died? ⇒ Boolean
-
#initialize ⇒ Gamer
constructor
A new instance of Gamer.
- #lost_a_life ⇒ Object
Constructor Details
#initialize ⇒ Gamer
Returns a new instance of Gamer.
7 8 9 10 11 |
# File 'lib/dsa_codebreaker_game/gamer.rb', line 7 def initialize @lives = 8 @history = [] @guess = ['_','_','_','_'] end |
Instance Attribute Details
#guess ⇒ Object
Returns the value of attribute guess.
5 6 7 |
# File 'lib/dsa_codebreaker_game/gamer.rb', line 5 def guess @guess end |
#history ⇒ Object
Returns the value of attribute history.
5 6 7 |
# File 'lib/dsa_codebreaker_game/gamer.rb', line 5 def history @history end |
#lives ⇒ Object
Returns the value of attribute lives.
5 6 7 |
# File 'lib/dsa_codebreaker_game/gamer.rb', line 5 def lives @lives end |
Instance Method Details
#died? ⇒ Boolean
17 18 19 |
# File 'lib/dsa_codebreaker_game/gamer.rb', line 17 def died? @lives < 0 end |
#lost_a_life ⇒ Object
13 14 15 |
# File 'lib/dsa_codebreaker_game/gamer.rb', line 13 def lost_a_life @lives -= 1 end |