Simulates Highline input for use in tests.
The simulator handles its own EOF
# File lib/highline/simulate.rb, line 35 def eof? false end
Simulate StringIO#getbyte by shifting a single character off of the next line of the script
# File lib/highline/simulate.rb, line 25 def getbyte line = gets if line.length > 0 char = line.slice! 0 @strings.unshift line char end end
Simulate StringIO#gets by shifting a string off of the script
# File lib/highline/simulate.rb, line 20 def gets @strings.shift end
Creates a simulator with an array of Strings as a script
# File lib/highline/simulate.rb, line 15 def initialize(strings) @strings = strings end
A wrapper method that temporarily replaces the Highline instance in $terminal with an instance of this object for the duration of the block
# File lib/highline/simulate.rb, line 40 def self.with(*strings) @input = $terminal.instance_variable_get :@input $terminal.instance_variable_set :@input, new(strings) yield ensure $terminal.instance_variable_set :@input, @input end