Class: Rbtclk::CountupTimer
- Inherits:
-
Object
- Object
- Rbtclk::CountupTimer
- Includes:
- ColorCode
- Defined in:
- lib/rbtclk/countup_timer.rb
Instance Method Summary collapse
-
#initialize(font: "clb8x8", format: "%X", color: "black") ⇒ CountupTimer
constructor
A new instance of CountupTimer.
- #show ⇒ Object
Methods included from ColorCode
Constructor Details
#initialize(font: "clb8x8", format: "%X", color: "black") ⇒ CountupTimer
Returns a new instance of CountupTimer.
15 16 17 18 19 |
# File 'lib/rbtclk/countup_timer.rb', line 15 def initialize(font: "clb8x8", format: "%X", color: "black") @artii = Artii::Base.new(font: font) @format = format @color = color end |
Instance Method Details
#show ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rbtclk/countup_timer.rb', line 21 def show Curses.init_screen Curses.start_color Curses.use_default_colors Curses.init_pair(1, translate(@color), -1) Curses.curs_set(0) @start_time = Time.now begin view_thread = Thread.new do loop do refresh sleep(1) end end input_thread = Thread.new do loop do case Curses.getch when "q" Thread.kill(view_thread) Thread.kill(input_thread) end end end view_thread.join input_thread.join ensure Curses.close_screen end end |