Module: Gobgems::WithColorOps

Included in:
Board
Defined in:
lib/gobgems/board.rb

Instance Method Summary collapse

Instance Method Details

#count(color) ⇒ Object



37
38
39
# File 'lib/gobgems/board.rb', line 37

def count(color)
  head_cell[color]
end

#exist?(color) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/gobgems/board.rb', line 41

def exist?(color)
  count(color) > 0
end

#pop(color) ⇒ Object



32
33
34
35
# File 'lib/gobgems/board.rb', line 32

def pop(color)
  raise "#{color} Underflow" if head_cell[color] == 0
  head_cell[color] -= 1
end

#push(color, amount = 1) ⇒ Object



28
29
30
# File 'lib/gobgems/board.rb', line 28

def push(color, amount=1)
  head_cell[color] += amount
end