Class: MM::Board
- Inherits:
-
Object
- Object
- MM::Board
- Defined in:
- lib/games/mastermind/board.rb
Instance Attribute Summary collapse
-
#number_of_cols ⇒ Object
Returns the value of attribute number_of_cols.
-
#number_of_rows ⇒ Object
Returns the value of attribute number_of_rows.
-
#pegs ⇒ Object
Returns the value of attribute pegs.
-
#result_pegs ⇒ Object
Returns the value of attribute result_pegs.
Instance Method Summary collapse
- #change_peg(row, col, new_value) ⇒ Object
- #display_values ⇒ Object
-
#initialize(args = {}) ⇒ Board
constructor
A new instance of Board.
- #pegs_current_row(number_of_turns_taken) ⇒ Object
- #result_pegs_current_row(number_of_turns_taken) ⇒ Object
- #result_values ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Board
Returns a new instance of Board.
5 6 7 8 9 10 |
# File 'lib/games/mastermind/board.rb', line 5 def initialize(args = {}) @number_of_rows = args[:number_of_rows] @number_of_cols = args[:number_of_cols] @pegs = args[:pegs] @result_pegs = args[:result_pegs] end |
Instance Attribute Details
#number_of_cols ⇒ Object
Returns the value of attribute number_of_cols.
3 4 5 |
# File 'lib/games/mastermind/board.rb', line 3 def number_of_cols @number_of_cols end |
#number_of_rows ⇒ Object
Returns the value of attribute number_of_rows.
3 4 5 |
# File 'lib/games/mastermind/board.rb', line 3 def number_of_rows @number_of_rows end |
#pegs ⇒ Object
Returns the value of attribute pegs.
3 4 5 |
# File 'lib/games/mastermind/board.rb', line 3 def pegs @pegs end |
#result_pegs ⇒ Object
Returns the value of attribute result_pegs.
3 4 5 |
# File 'lib/games/mastermind/board.rb', line 3 def result_pegs @result_pegs end |
Instance Method Details
#change_peg(row, col, new_value) ⇒ Object
12 13 14 15 |
# File 'lib/games/mastermind/board.rb', line 12 def change_peg(row, col, new_value) peg_to_change = retrieve_peg(row, col) peg_to_change.change_value(new_value) end |
#display_values ⇒ Object
17 18 19 |
# File 'lib/games/mastermind/board.rb', line 17 def display_values pegs.display_values end |
#pegs_current_row(number_of_turns_taken) ⇒ Object
25 26 27 |
# File 'lib/games/mastermind/board.rb', line 25 def pegs_current_row(number_of_turns_taken) pegs.current_row(number_of_turns_taken) end |
#result_pegs_current_row(number_of_turns_taken) ⇒ Object
29 30 31 |
# File 'lib/games/mastermind/board.rb', line 29 def result_pegs_current_row(number_of_turns_taken) result_pegs.current_row(number_of_turns_taken) end |
#result_values ⇒ Object
21 22 23 |
# File 'lib/games/mastermind/board.rb', line 21 def result_values result_pegs.display_values end |