Class: Cliptic::Windows::Cell

Inherits:
Object
  • Object
show all
Defined in:
lib/cliptic/windows.rb

Direct Known Subclasses

Main::Windows::Cell

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#gridObject (readonly)

Returns the value of attribute grid.



170
171
172
# File 'lib/cliptic/windows.rb', line 170

def grid
  @grid
end

#posObject (readonly)

Returns the value of attribute pos.



170
171
172
# File 'lib/cliptic/windows.rb', line 170

def pos
  @pos
end

#sqObject (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