Class: Vop::TestableShellInput

Inherits:
Object
  • Object
show all
Defined in:
lib/vop/shell/shell_input_testable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTestableShellInput

Returns a new instance of TestableShellInput.



8
9
10
11
# File 'lib/vop/shell/shell_input_testable.rb', line 8

def initialize
  @answers = []
  @exit = false
end

Instance Attribute Details

#answersObject

Returns the value of attribute answers.



5
6
7
# File 'lib/vop/shell/shell_input_testable.rb', line 5

def answers
  @answers
end

#exitObject (readonly)

Returns the value of attribute exit.



6
7
8
# File 'lib/vop/shell/shell_input_testable.rb', line 6

def exit
  @exit
end

Instance Method Details

#read(prompt) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/vop/shell/shell_input_testable.rb', line 13

def read(prompt)
  answer = @answers.shift
  if answer.nil?
    raise "no more pre-defined answers (asked for '#{prompt}')"
  end
  answer
end