Parent

HighLine::Simulate

Simulates Highline input for use in tests.

Public Class Methods

new(strings) click to toggle source

Creates a simulator with an array of Strings as a script

    # File lib/highline/simulate.rb, line 17
17:     def initialize(strings)
18:       @strings = strings
19:     end
with(*strings) click to toggle source

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 42
42:     def self.with(*strings)
43:       @input = $terminal.instance_variable_get :@input
44:       $terminal.instance_variable_set :@input, new(strings)
45:       yield
46:     ensure
47:       $terminal.instance_variable_set :@input, @input
48:     end

Public Instance Methods

eof?() click to toggle source

The simulator handles its own EOF

    # File lib/highline/simulate.rb, line 37
37:     def eof?
38:       false
39:     end
getbyte() click to toggle source

Simulate StringIO#getbyte by shifting a single character off of the next line of the script

    # File lib/highline/simulate.rb, line 27
27:     def getbyte
28:       line = gets
29:       if line.length > 0
30:         char = line.slice! 0
31:         @strings.unshift line
32:         char
33:       end
34:     end
gets() click to toggle source

Simulate StringIO#gets by shifting a string off of the script

    # File lib/highline/simulate.rb, line 22
22:     def gets
23:       @strings.shift
24:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.