Class: Tetris::Model::Block
- Inherits:
-
Object
- Object
- Tetris::Model::Block
- Defined in:
- lib/glimmer-dsl-opal/samples/elaborate/tetris/model/block.rb
Constant Summary collapse
- COLOR_CLEAR =
:white
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
Instance Method Summary collapse
-
#clear ⇒ Object
Clears block color.
- #clear? ⇒ Boolean
-
#initialize(color = COLOR_CLEAR) ⇒ Block
constructor
Initializes with color.
- #occupied? ⇒ Boolean
Constructor Details
#initialize(color = COLOR_CLEAR) ⇒ Block
Initializes with color. Default color (gray) signifies an empty block
30 31 32 |
# File 'lib/glimmer-dsl-opal/samples/elaborate/tetris/model/block.rb', line 30 def initialize(color = COLOR_CLEAR) @color = color end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
27 28 29 |
# File 'lib/glimmer-dsl-opal/samples/elaborate/tetris/model/block.rb', line 27 def color @color end |
Instance Method Details
#clear ⇒ Object
Clears block color. ‘quietly` option indicates if it should not notify observers by setting value quietly via variable not attribute writer.
35 36 37 |
# File 'lib/glimmer-dsl-opal/samples/elaborate/tetris/model/block.rb', line 35 def clear self.color = COLOR_CLEAR unless self.color == COLOR_CLEAR end |
#clear? ⇒ Boolean
39 40 41 |
# File 'lib/glimmer-dsl-opal/samples/elaborate/tetris/model/block.rb', line 39 def clear? self.color == COLOR_CLEAR end |
#occupied? ⇒ Boolean
43 44 45 |
# File 'lib/glimmer-dsl-opal/samples/elaborate/tetris/model/block.rb', line 43 def occupied? !clear? end |