Sha256: ab51a3991fb213c377dfffb483e9e3fec33d4eafdc59dcb3553b131c73178e44
Contents?: true
Size: 1.53 KB
Versions: 3
Compression:
Stored size: 1.53 KB
Contents
require File.expand_path(File.join(File.dirname(__FILE__), "input_method/base")) require File.expand_path(File.join(File.dirname(__FILE__), "input_method/readline")) require File.expand_path(File.join(File.dirname(__FILE__), "input_method/io")) require File.expand_path(File.join(File.dirname(__FILE__), "input_method/file")) require File.expand_path(File.join(File.dirname(__FILE__), "output_method/base")) require File.expand_path(File.join(File.dirname(__FILE__), "output_method/io")) require 'stringio' module Rink module IOMethods 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 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 end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rink-1.0.2 | lib/rink/io_methods.rb |
rink-1.0.1 | lib/rink/io_methods.rb |
rink-1.0.0 | lib/rink/io_methods.rb |