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
Returns a new instance of Game.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/game.rb', line 17 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.
7 8 9 |
# File 'lib/game.rb', line 7 def answer @answer end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
7 8 9 |
# File 'lib/game.rb', line 7 def command @command end |
#guess_count ⇒ Object (readonly)
Returns the value of attribute guess_count.
7 8 9 |
# File 'lib/game.rb', line 7 def guess_count @guess_count end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
7 8 9 |
# File 'lib/game.rb', line 7 def input @input end |
#judge ⇒ Object (readonly)
Returns the value of attribute judge.
7 8 9 |
# File 'lib/game.rb', line 7 def judge @judge end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
7 8 9 |
# File 'lib/game.rb', line 7 def end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
7 8 9 |
# File 'lib/game.rb', line 7 def output @output end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
7 8 9 |
# File 'lib/game.rb', line 7 def start_time @start_time end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
7 8 9 |
# File 'lib/game.rb', line 7 def table @table end |
Instance Method Details
#play ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/game.rb', line 30 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 |