Class: Rbtclk::Clock
Instance Method Summary collapse
-
#initialize(font: "clb8x8", format: "%X", color: "black") ⇒ Clock
constructor
A new instance of Clock.
- #show ⇒ Object
Methods included from ColorCode
Constructor Details
#initialize(font: "clb8x8", format: "%X", color: "black") ⇒ Clock
14 15 16 17 18 |
# File 'lib/rbtclk/clock.rb', line 14 def initialize(font: "clb8x8", format: "%X", color: "black") @artii = Artii::Base.new(font: font) @format = format @color = color end |
Instance Method Details
#show ⇒ Object
20 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 |
# File 'lib/rbtclk/clock.rb', line 20 def show Curses.init_screen Curses.start_color Curses.use_default_colors Curses.init_pair(1, translate(@color), -1) Curses.curs_set(0) 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 |