Module: Rink::IOMethods
- Included in:
- Console
- Defined in:
- lib/rink/io_methods.rb
Instance Method Summary collapse
Instance Method Details
#setup_input_method(input) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rink/io_methods.rb', line 11 def setup_input_method(input) @input = case input when Rink::InputMethod::Base input when STDIN defined?(Rink::InputMethod::Readline) ? Rink::InputMethod::Readline.new : Rink::InputMethod::IO.new when File Rink::InputMethod::File.new(input) when String Rink::InputMethod::IO.new(StringIO.new(input)) when ::IO, StringIO Rink::InputMethod::IO.new(input) #when nil # nil else raise ArgumentError, "Unexpected input type: #{input.class}" end end |
#setup_output_method(output) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rink/io_methods.rb', line 29 def setup_output_method(output) @output = case output when Rink::OutputMethod::Base output when STDOUT, STDERR, ::IO, StringIO then Rink::OutputMethod::IO.new(output) when String Rink::OutputMethod::IO.new(StringIO.new(output)) when nil then nil else raise ArgumentError, "Unexpected ouptut type: #{output.class}" end end |