Skip to content

Instantly share code, notes, and snippets.

@Jeweller-Tsai
Created April 21, 2012 12:45
Show Gist options
  • Save Jeweller-Tsai/2436935 to your computer and use it in GitHub Desktop.
Save Jeweller-Tsai/2436935 to your computer and use it in GitHub Desktop.
How to take STDIN in the middle of a method execution?

How to take STDIN in the middle of a method execution?

 #!/usr/bin/env ruby

class CLI < Thor
  def search
    # ...

    selected = gets.chomp.to_i # this will raise: Broken pipe (Errno::EPIPE)

    # ...
  end
end

CLI.start
@towerhe
Copy link

towerhe commented Apr 22, 2012

Sorry, for now I have no idea about it. You should check the status of your STDIN.

@Jeweller-Tsai
Copy link
Author

Jeweller-Tsai commented Apr 22, 2012 via email

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