Class: Game
- Inherits:
-
Object
- Object
- Game
- Defined in:
- lib/game.rb
Instance Attribute Summary collapse
-
#answer ⇒ Object
readonly
Returns the value of attribute answer.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#guess_count ⇒ Object
readonly
Returns the value of attribute guess_count.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#judge ⇒ Object
readonly
Returns the value of attribute judge.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
-
#initialize(input, output, messages) ⇒ Game
constructor
A new instance of Game.
- #play ⇒ Object
Constructor Details
#initialize(input, output, messages) ⇒ Game
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/game.rb', line 19 def initialize(input, output, ) @answer = Colors.new.secret_answer @judge = Validate.new(@answer) @start_time = Time.now @table = Table.new @input = input @output = output = @command = "" @guess_count = 0 @old_guess = [] end |
Instance Attribute Details
#answer ⇒ Object (readonly)
Returns the value of attribute answer.
9 10 11 |
# File 'lib/game.rb', line 9 def answer @answer end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
9 10 11 |
# File 'lib/game.rb', line 9 def command @command end |
#guess_count ⇒ Object (readonly)
Returns the value of attribute guess_count.
9 10 11 |
# File 'lib/game.rb', line 9 def guess_count @guess_count end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
9 10 11 |
# File 'lib/game.rb', line 9 def input @input end |
#judge ⇒ Object (readonly)
Returns the value of attribute judge.
9 10 11 |
# File 'lib/game.rb', line 9 def judge @judge end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
9 10 11 |
# File 'lib/game.rb', line 9 def end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
9 10 11 |
# File 'lib/game.rb', line 9 def output @output end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
9 10 11 |
# File 'lib/game.rb', line 9 def start_time @start_time end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
9 10 11 |
# File 'lib/game.rb', line 9 def table @table end |
Instance Method Details
#play ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/game.rb', line 32 def play output.puts .game_start output.puts table.show until win? || lose? output.print .guess_prompt @command = input.gets.chomp.downcase guess_counter turn_evaluation end end |