Skip to content

Instantly share code, notes, and snippets.

@JiriChara
Last active December 11, 2015 15:38
Show Gist options
  • Save JiriChara/4622137 to your computer and use it in GitHub Desktop.
Save JiriChara/4622137 to your computer and use it in GitHub Desktop.
EventMachine respond to one character from stdin
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