Created
December 14, 2009 18:26
-
-
Save defunkt/256280 to your computer and use it in GitHub Desktop.
Transparent stdin / stdout
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
| class MyApp | |
| attr_accessor :input, :output | |
| def initialize | |
| @input = $stdin | |
| @output = $stdout | |
| end | |
| def prompt_user | |
| user_selection = gets.chomp # => 'ponies' | |
| puts "User selected: #{user_selection}" # Displays User selected: ponies | |
| user_selection | |
| end | |
| def puts(*args) | |
| @output.puts(*args) | |
| end | |
| def gets(*args) | |
| @output.gets(*args) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment