Class: Cliptic::Windows::Cell
- Inherits:
-
Object
- Object
- Cliptic::Windows::Cell
- Defined in:
- lib/cliptic/windows.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#grid ⇒ Object
readonly
Returns the value of attribute grid.
-
#pos ⇒ Object
readonly
Returns the value of attribute pos.
-
#sq ⇒ Object
readonly
Returns the value of attribute sq.
Instance Method Summary collapse
- #focus(y: 0, x: 0) ⇒ Object
-
#initialize(sq:, grid:) ⇒ Cell
constructor
A new instance of Cell.
- #write(char) ⇒ Object
Constructor Details
#initialize(sq:, grid:) ⇒ Cell
Returns a new instance of Cell.
171 172 173 |
# File 'lib/cliptic/windows.rb', line 171 def initialize(sq:, grid:) @sq, @grid, @pos = sq, grid, calc_abs_pos(**sq) end |
Instance Attribute Details
#grid ⇒ Object (readonly)
Returns the value of attribute grid.
170 171 172 |
# File 'lib/cliptic/windows.rb', line 170 def grid @grid end |
#pos ⇒ Object (readonly)
Returns the value of attribute pos.
170 171 172 |
# File 'lib/cliptic/windows.rb', line 170 def pos @pos end |
#sq ⇒ Object (readonly)
Returns the value of attribute sq.
170 171 172 |
# File 'lib/cliptic/windows.rb', line 170 def sq @sq end |
Instance Method Details
#focus(y: 0, x: 0) ⇒ Object
174 175 176 177 |
# File 'lib/cliptic/windows.rb', line 174 def focus(y:0, x:0) grid.setpos(*[y,x].zip(pos.values).map(&:sum)) self end |
#write(char) ⇒ Object
178 179 180 |
# File 'lib/cliptic/windows.rb', line 178 def write(char) focus.grid << char; self end |