Module: Roebe::BlinkingCursor
- Defined in:
- lib/roebe/toplevel_methods/blinking_cursor.rb
Constant Summary collapse
- B =
#
B
This is actually the “backspace” character, so the whole “blinking” effect is nothing but repositioning the cursor backwards.
#
"\b"
Class Method Summary collapse
-
.backspace_twice ⇒ Object
# === Roebe::BlinkingCursor.backspace_twice ========================================================================== #.
-
.blink ⇒ Object
# === Roebe::BlinkingCursor.blink.
-
.default_sleep(i = 0.5) ⇒ Object
# === Roebe::BlinkingCursor.default_sleep ========================================================================== #.
Class Method Details
.backspace_twice ⇒ Object
#
Roebe::BlinkingCursor.backspace_twice
#
47 48 49 |
# File 'lib/roebe/toplevel_methods/blinking_cursor.rb', line 47 def self.backspace_twice print "#{B}#{B}" end |
.blink ⇒ Object
#
Roebe::BlinkingCursor.blink
This is the method that can be used to blink.
#
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/roebe/toplevel_methods/blinking_cursor.rb', line 56 def self.blink loop { # ====================================================================== # # Show the first prompt-type next: # ====================================================================== # print '> ' default_sleep backspace_twice # ====================================================================== # # Show the other prompt-type next: # ====================================================================== # print ' ' default_sleep backspace_twice # user_input = $stdin.gets.chomp # break if user_input.size > 0 } end |
.default_sleep(i = 0.5) ⇒ Object
#
Roebe::BlinkingCursor.default_sleep
#
35 36 37 38 39 40 41 42 |
# File 'lib/roebe/toplevel_methods/blinking_cursor.rb', line 35 def self.default_sleep(i = 0.5) begin sleep(i) rescue Interrupt puts # Make a proper newline, on-exit. exit end end |