Class: Minesweeper::BaseCell
- Inherits:
-
Object
- Object
- Minesweeper::BaseCell
- Extended by:
- Forwardable
- Defined in:
- lib/minesweeper/base_cell.rb
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #bomb? ⇒ Boolean
-
#initialize ⇒ BaseCell
constructor
A new instance of BaseCell.
- #open! ⇒ Object
- #toggle_bomb_flag! ⇒ Object
Constructor Details
#initialize ⇒ BaseCell
Returns a new instance of BaseCell.
11 12 13 |
# File 'lib/minesweeper/base_cell.rb', line 11 def initialize @state = initial_state end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
9 10 11 |
# File 'lib/minesweeper/base_cell.rb', line 9 def state @state end |
Instance Method Details
#bomb? ⇒ Boolean
15 16 17 |
# File 'lib/minesweeper/base_cell.rb', line 15 def bomb? raise NotImplementedError, 'defined in subclass' end |
#open! ⇒ Object
32 33 34 |
# File 'lib/minesweeper/base_cell.rb', line 32 def open!(*) raise NotImplementedError, 'defined in subclass' end |
#toggle_bomb_flag! ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/minesweeper/base_cell.rb', line 19 def toggle_bomb_flag! return if opened? if marked_as_bomb? state.view = ' ' state.color = COLOR_MAGENTA state.status = :initial else state.view = '*' state.color = COLOR_MAGENTA state.status = :marked_as_bomb end end |