Class: Termworld::Resources::Chip
- Inherits:
-
Object
- Object
- Termworld::Resources::Chip
- Defined in:
- lib/termworld/resources/chip.rb
Instance Attribute Summary collapse
-
#movable ⇒ Object
readonly
Returns the value of attribute movable.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(y: nil, x: nil, key:) ⇒ Chip
constructor
A new instance of Chip.
- #rect ⇒ Object
Constructor Details
#initialize(y: nil, x: nil, key:) ⇒ Chip
Returns a new instance of Chip.
7 8 9 10 11 12 |
# File 'lib/termworld/resources/chip.rb', line 7 def initialize(y: nil, x: nil, key:) @y = y @x = x @key = key data end |
Instance Attribute Details
#movable ⇒ Object (readonly)
Returns the value of attribute movable.
6 7 8 |
# File 'lib/termworld/resources/chip.rb', line 6 def movable @movable end |
Instance Method Details
#data ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/termworld/resources/chip.rb', line 14 def data case @key when "00" @movable = true { background_color: {r: 300, g: 300, b: 300}, } when "01" @movable = false { background_color: {r: 0, g: 0, b: 0}, } when "pl" { background_color: {r: 200, b: 200, g: 800}, } end end |
#rect ⇒ Object
33 34 35 36 37 38 |
# File 'lib/termworld/resources/chip.rb', line 33 def rect TermCanvas::Rect.new( x: @x, y: @y, width: 2, height: 1, background_color: data[:background_color], ) end |