Class: Tetris::Model::Block

Inherits:
Object
  • Object
show all
Defined in:
lib/glimmer-dsl-opal/samples/elaborate/tetris/model/block.rb

Constant Summary collapse

COLOR_CLEAR =
:white

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#colorObject

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

#clearObject

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

Returns:

  • (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

Returns:

  • (Boolean)


43
44
45
# File 'lib/glimmer-dsl-opal/samples/elaborate/tetris/model/block.rb', line 43

def occupied?
  !clear?
end