Last active
December 11, 2015 15:38
-
-
Save JiriChara/4622137 to your computer and use it in GitHub Desktop.
EventMachine respond to one character from stdin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "eventmachine" | |
require "highline/import" | |
def get_user_input | |
input = HighLine.new | |
c = ask('') { |q| q.character = true; q.echo = false } | |
# Do something | |
print c | |
get_user_input | |
end | |
EM.run { | |
EM.defer do | |
get_user_input | |
end | |
puts "Just test, that reactor is not blocked." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment