Class: TTT::Square

Inherits:
Object
  • Object
show all
Defined in:
lib/tictactoe/square.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#colObject (readonly)

Returns the value of attribute col.



4
5
6
# File 'lib/tictactoe/square.rb', line 4

def col
  @col
end

#display_valueObject

Returns the value of attribute display_value.



3
4
5
# File 'lib/tictactoe/square.rb', line 3

def display_value
  @display_value
end

#rowObject (readonly)

Returns the value of attribute row.



4
5
6
# File 'lib/tictactoe/square.rb', line 4

def row
  @row
end

#valueObject

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

Returns:

  • (Boolean)


18
19
20
# File 'lib/tictactoe/square.rb', line 18

def empty?
  return true unless full?
end

#full?Boolean

Returns:

  • (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