Skip to content

Instantly share code, notes, and snippets.

@raluka
Forked from defunkt/stdin.rb
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save raluka/f437fe021c0af4e6991e to your computer and use it in GitHub Desktop.

Select an option

Save raluka/f437fe021c0af4e6991e to your computer and use it in GitHub Desktop.
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