Module: Stones::WithStones
- Included in:
- Board
- Defined in:
- lib/stones/board/with_stones.rb
Instance Method Summary collapse
- #clear! ⇒ Object
- #count(color) ⇒ Object
- #exist?(color) ⇒ Boolean
- #pop!(color) ⇒ Object
- #push!(color, amount = 1) ⇒ Object
Instance Method Details
#clear! ⇒ Object
12 13 14 |
# File 'lib/stones/board/with_stones.rb', line 12 def clear! @cells = self.class.empty_cells(*size) end |
#count(color) ⇒ Object
16 17 18 |
# File 'lib/stones/board/with_stones.rb', line 16 def count(color) head_cell[color] end |
#exist?(color) ⇒ Boolean
20 21 22 |
# File 'lib/stones/board/with_stones.rb', line 20 def exist?(color) count(color) > 0 end |
#pop!(color) ⇒ Object
7 8 9 10 |
# File 'lib/stones/board/with_stones.rb', line 7 def pop!(color) raise "#{color} Underflow" if head_cell[color] == 0 head_cell[color] -= 1 end |
#push!(color, amount = 1) ⇒ Object
3 4 5 |
# File 'lib/stones/board/with_stones.rb', line 3 def push!(color, amount=1) head_cell[color] += amount end |