Class: TTT::Square
- Inherits:
-
Object
- Object
- TTT::Square
- Defined in:
- lib/tictactoe/square.rb
Instance Attribute Summary collapse
-
#col ⇒ Object
readonly
Returns the value of attribute col.
-
#display_value ⇒ Object
Returns the value of attribute display_value.
-
#row ⇒ Object
readonly
Returns the value of attribute row.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #change_value(new_value) ⇒ Object
- #empty? ⇒ Boolean
- #full? ⇒ Boolean
-
#initialize(args) ⇒ Square
constructor
A new instance of Square.
Constructor Details
#initialize(args) ⇒ Square
Returns a new instance of Square.
6 7 8 9 10 11 |
# File 'lib/tictactoe/square.rb', line 6 def initialize(args) @value = args[:value] @display_value = args[:display_value] @row = args[:row] @col = args[:col] end |
Instance Attribute Details
#col ⇒ Object (readonly)
Returns the value of attribute col.
4 5 6 |
# File 'lib/tictactoe/square.rb', line 4 def col @col end |
#display_value ⇒ Object
Returns the value of attribute display_value.
3 4 5 |
# File 'lib/tictactoe/square.rb', line 3 def display_value @display_value end |
#row ⇒ Object (readonly)
Returns the value of attribute row.
4 5 6 |
# File 'lib/tictactoe/square.rb', line 4 def row @row end |
#value ⇒ Object
Returns the value of attribute value.
3 4 5 |
# File 'lib/tictactoe/square.rb', line 3 def value @value end |
Instance Method Details
#change_value(new_value) ⇒ Object
13 14 15 16 |
# File 'lib/tictactoe/square.rb', line 13 def change_value(new_value) self.value = new_value self.display_value = new_value end |
#empty? ⇒ Boolean
18 19 20 |
# File 'lib/tictactoe/square.rb', line 18 def empty? return true unless full? end |
#full? ⇒ Boolean
22 23 24 25 26 27 28 |
# File 'lib/tictactoe/square.rb', line 22 def full? if value != nil return true else return false end end |