Class: Minesweeper::Cells::Base
- Inherits:
-
Object
- Object
- Minesweeper::Cells::Base
- Extended by:
- Forwardable
- Defined in:
- lib/minesweeper/cells/base.rb
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #bomb? ⇒ Boolean
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #open! ⇒ Object
- #toggle_bomb_flag! ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
12 13 14 |
# File 'lib/minesweeper/cells/base.rb', line 12 def initialize @state = initial_state end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
10 11 12 |
# File 'lib/minesweeper/cells/base.rb', line 10 def state @state end |
Instance Method Details
#bomb? ⇒ Boolean
16 17 18 |
# File 'lib/minesweeper/cells/base.rb', line 16 def bomb? raise NotImplementedError, 'defined in subclass' end |
#open! ⇒ Object
33 34 35 |
# File 'lib/minesweeper/cells/base.rb', line 33 def open!(*) raise NotImplementedError, 'defined in subclass' end |
#toggle_bomb_flag! ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/minesweeper/cells/base.rb', line 20 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 |