Skip to content

Instantly share code, notes, and snippets.

@benlangfeld
Created February 3, 2012 12:00
Show Gist options
  • Save benlangfeld/1729843 to your computer and use it in GitHub Desktop.
Save benlangfeld/1729843 to your computer and use it in GitHub Desktop.
I am struggling a little with using $stdin.gets within a Pry session. My use case is a console method presenting a list of numbered options, and then blocking on a choice (an integer) before resuming that method. I'm seeing this: https://gist.github.com/1
require 'pry'
def foo
gets
end
pry
{11:59}[ruby-1.9.3]~/code/VoIP/adhearsion/testapps/general ben% ruby foo.rb
[1] pry(main)> foo
1^M^M^M^M^CInterrupt:
from foo.rb:4:in `gets'
[2] pry(main)> exit
Copy link

ghost commented Feb 3, 2012

$ ruby /tmp/bla.rb

Frame number: 0/1
Frame type: eval

From: /tmp/bla.rb @ line 7:

2: 
3: def foo
4:   gets
5: end
6: 

=> 7: pry
8:

[1] pry(main)> foo
HEY WORLD HOW ARE YOU TODAY?
=> "HEY WORLD HOW ARE YOU TODAY?\n"
[2] pry(main)>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment