Class: Cell

Inherits:
Object
  • Object
show all
Defined in:
lib/fiveinarow/cell.rb

Constant Summary collapse

EMPTY =
0
PLAYER_A =
1
PLAYER_B =
2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row, col, val) ⇒ Cell

Returns a new instance of Cell.



10
11
12
13
14
# File 'lib/fiveinarow/cell.rb', line 10

def initialize(row, col, val)
  @row = row
  @col = col
  @value = val
end

Instance Attribute Details

#colObject (readonly)

Returns the value of attribute col.



4
5
6
# File 'lib/fiveinarow/cell.rb', line 4

def col
  @col
end

#rowObject (readonly)

Returns the value of attribute row.



3
4
5
# File 'lib/fiveinarow/cell.rb', line 3

def row
  @row
end

#valueObject

Returns the value of attribute value.



2
3
4
# File 'lib/fiveinarow/cell.rb', line 2

def value
  @value
end

Instance Method Details

#a?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/fiveinarow/cell.rb', line 24

def a?
  @value == Cell::PLAYER_A
end

#b?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/fiveinarow/cell.rb', line 28

def b?
  @value == Cell::PLAYER_B
end

#e?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/fiveinarow/cell.rb', line 20

def e?
  @value == Cell::EMPTY
end

#set(v) ⇒ Object



16
17
18
# File 'lib/fiveinarow/cell.rb', line 16

def set(v)
  @value = v
end