Class: Cliptic::Interface::Selector

Inherits:
Windows::Window show all
Defined in:
lib/cliptic/interface.rb

Direct Known Subclasses

Date_Selector

Constant Summary

Constants included from Chars

Chars::Block, Chars::HL, Chars::LL, Chars::LS, Chars::LU, Chars::MS, Chars::Nums, Chars::RL, Chars::RS, Chars::RU, Chars::TD, Chars::TL, Chars::TR, Chars::TU, Chars::Tick, Chars::VL, Chars::XX

Instance Attribute Summary collapse

Attributes inherited from Windows::Window

#centered_x, #centered_y, #col, #line, #x, #y

Instance Method Summary collapse

Methods inherited from Windows::Window

#add_str, #bold, #clear, #color, #move, #refresh, #reset_attrs, #reset_pos, #setpos, #standend, #standout, #time_str, #wrap_str

Methods included from Chars

small_num

Constructor Details

#initialize(opts:, ctrls:, x:, line:, tick: nil, y: opts.length, col: nil) ⇒ Selector

Returns a new instance of Selector.



108
109
110
111
112
113
# File 'lib/cliptic/interface.rb', line 108

def initialize(opts:, ctrls:, x:, line:,
               tick:nil, y:opts.length, col:nil)
  super(y:y, x:x, line:line, col:col)
  @opts, @ctrls, @tick = opts, ctrls, tick
  @cursor, @run = 0, true
end

Instance Attribute Details

#ctrlsObject (readonly)

Returns the value of attribute ctrls.



106
107
108
# File 'lib/cliptic/interface.rb', line 106

def ctrls
  @ctrls
end

#cursorObject

Returns the value of attribute cursor.



107
108
109
# File 'lib/cliptic/interface.rb', line 107

def cursor
  @cursor
end

#optsObject (readonly)

Returns the value of attribute opts.



106
107
108
# File 'lib/cliptic/interface.rb', line 106

def opts
  @opts
end

#runObject (readonly)

Returns the value of attribute run.



106
107
108
# File 'lib/cliptic/interface.rb', line 106

def run
  @run
end

#tickObject (readonly)

Returns the value of attribute tick.



106
107
108
# File 'lib/cliptic/interface.rb', line 106

def tick
  @tick
end

Instance Method Details

#selectObject



114
115
116
117
118
119
# File 'lib/cliptic/interface.rb', line 114

def select
  while @run
    draw
    ctrls[getch]&.call
  end
end

#stopObject



120
121
122
# File 'lib/cliptic/interface.rb', line 120

def stop
  @run = false
end