Class: Cliptic::Main::Windows::Cell

Inherits:
Windows::Cell show all
Defined in:
lib/cliptic/main.rb

Instance Attribute Summary collapse

Attributes inherited from Windows::Cell

#grid, #pos, #sq

Instance Method Summary collapse

Methods inherited from Windows::Cell

#focus

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

#blockedObject (readonly)

Returns the value of attribute blocked.



63
64
65
# File 'lib/cliptic/main.rb', line 63

def blocked
  @blocked
end

#bufferObject (readonly)

Returns the value of attribute buffer.



63
64
65
# File 'lib/cliptic/main.rb', line 63

def buffer
  @buffer
end

#indexObject (readonly)

Returns the value of attribute index.



63
64
65
# File 'lib/cliptic/main.rb', line 63

def index
  @index
end

#lockedObject

Returns the value of attribute locked.



64
65
66
# File 'lib/cliptic/main.rb', line 64

def locked
  @locked
end

Instance Method Details

#clearObject



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_blockObject



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

#underlineObject



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

#unlockObject



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