Class: Cliptic::Main::Windows::Cell
- Inherits:
-
Windows::Cell
- Object
- Windows::Cell
- Cliptic::Main::Windows::Cell
- Defined in:
- lib/cliptic/main.rb
Instance Attribute Summary collapse
-
#blocked ⇒ Object
readonly
Returns the value of attribute blocked.
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#locked ⇒ Object
Returns the value of attribute locked.
Attributes inherited from Windows::Cell
Instance Method Summary collapse
- #clear ⇒ Object
- #color(cp) ⇒ Object
-
#initialize(sq:, grid:) ⇒ Cell
constructor
A new instance of Cell.
- #set_block ⇒ Object
- #set_number(n: index, active: false) ⇒ Object
- #underline ⇒ Object
- #unlock ⇒ Object
- #write(char = @buffer) ⇒ Object
Methods inherited from Windows::Cell
Constructor Details
#initialize(sq:, grid:) ⇒ Cell
Returns a new instance of Cell.
65 66 67 68 69 |
# File 'lib/cliptic/main.rb', line 65 def initialize(sq:, grid:) super(sq:sq, grid:grid) @index, @blocked, @locked = false, false, false @buffer = " " end |
Instance Attribute Details
#blocked ⇒ Object (readonly)
Returns the value of attribute blocked.
63 64 65 |
# File 'lib/cliptic/main.rb', line 63 def blocked @blocked end |
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
63 64 65 |
# File 'lib/cliptic/main.rb', line 63 def buffer @buffer end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
63 64 65 |
# File 'lib/cliptic/main.rb', line 63 def index @index end |
#locked ⇒ Object
Returns the value of attribute locked.
64 65 66 |
# File 'lib/cliptic/main.rb', line 64 def locked @locked end |
Instance Method Details
#clear ⇒ Object
103 104 105 106 |
# File 'lib/cliptic/main.rb', line 103 def clear @locked, @blocked = false, false @buffer = " " end |
#color(cp) ⇒ Object
98 99 100 101 102 |
# File 'lib/cliptic/main.rb', line 98 def color(cp) grid.color(cp) write grid.color end |
#set_block ⇒ Object
79 80 81 82 83 |
# File 'lib/cliptic/main.rb', line 79 def set_block focus(x:-1).grid.color($colors[:block]) << Chars::Block @blocked = true grid.color end |
#set_number(n: index, active: false) ⇒ Object
70 71 72 73 74 75 76 77 78 |
# File 'lib/cliptic/main.rb', line 70 def set_number(n:index, active:false) @index = n unless index grid.color(active ? $colors[:active_num] : $colors[:num]) focus(y:-1, x:-1) grid << Chars.small_num(n) grid.color end |
#underline ⇒ Object
84 85 86 87 88 |
# File 'lib/cliptic/main.rb', line 84 def underline grid.attron(Curses::A_UNDERLINE) write grid.attroff(Curses::A_UNDERLINE) end |
#unlock ⇒ Object
95 96 97 |
# File 'lib/cliptic/main.rb', line 95 def unlock @locked = false unless @blocked; self end |
#write(char = @buffer) ⇒ Object
89 90 91 92 93 94 |
# File 'lib/cliptic/main.rb', line 89 def write(char=@buffer) unless @locked super(char) @buffer = char end; self end |