Class: Rbtclk::CountupTimer
- Inherits:
-
Object
- Object
- Rbtclk::CountupTimer
- Defined in:
- lib/rbtclk/countup_timer.rb
Instance Method Summary collapse
-
#initialize(font: "clb8x8", format: "%X") ⇒ CountupTimer
constructor
A new instance of CountupTimer.
- #show ⇒ Object
Constructor Details
#initialize(font: "clb8x8", format: "%X") ⇒ CountupTimer
Returns a new instance of CountupTimer.
6 7 8 9 |
# File 'lib/rbtclk/countup_timer.rb', line 6 def initialize(font: "clb8x8", format: "%X") @artii = Artii::Base.new(font: font, format: "%X") @format = format end |
Instance Method Details
#show ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rbtclk/countup_timer.rb', line 11 def show Curses.init_screen 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" exit end end end view_thread.join input_thread.join ensure Curses.close_screen end end |