Class: Keyboard
Constant Summary collapse
- MAX_CHAR =
255
- ENTER =
13
- ESCAPE =
27
- IS_18 =
RUBY_VERSION =~ /^1\.8/
- SEQUENCE_TIMEOUT =
0.005
- NOTHING =
getch returns this as ‘nothing’ on 1.8 but nil on 1.9.2
(2**32 - 1)
- A_TO_Z =
('a'..'z').to_a
Class Method Summary collapse
Class Method Details
.input(&block) ⇒ Object
12 13 14 |
# File 'lib/ruco/keyboard.rb', line 12 def self.input(&block) @input = block end |
.output ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ruco/keyboard.rb', line 16 def self.output @sequence = [] @started = Time.now.to_f loop do key = fetch_user_input if sequence_finished? sequence_to_keys(@sequence).each{|k| yield k } @sequence = [] end next unless key append_to_sequence key end end |