Class: Retest::Prompt
- Inherits:
-
Object
- Object
- Retest::Prompt
- Includes:
- Observable
- Defined in:
- lib/retest/prompt.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
Returns the value of attribute input.
-
#output ⇒ Object
Returns the value of attribute output.
Class Method Summary collapse
Instance Method Summary collapse
- #ask_which_test_to_use(path, files) ⇒ Object
-
#initialize(input: nil, output: nil) ⇒ Prompt
constructor
A new instance of Prompt.
- #puts(*args) ⇒ Object
- #read_output ⇒ Object
Constructor Details
#initialize(input: nil, output: nil) ⇒ Prompt
Returns a new instance of Prompt.
14 15 16 17 |
# File 'lib/retest/prompt.rb', line 14 def initialize(input: nil, output: nil) @input = input || $stdin @output = output || $stdout end |
Instance Attribute Details
#input ⇒ Object
Returns the value of attribute input.
13 14 15 |
# File 'lib/retest/prompt.rb', line 13 def input @input end |
#output ⇒ Object
Returns the value of attribute output.
13 14 15 |
# File 'lib/retest/prompt.rb', line 13 def output @output end |
Class Method Details
.ask_which_test_to_use(path, files) ⇒ Object
5 6 7 |
# File 'lib/retest/prompt.rb', line 5 def self.ask_which_test_to_use(path, files) new.ask_which_test_to_use(path, files) end |
.puts(*args) ⇒ Object
9 10 11 |
# File 'lib/retest/prompt.rb', line 9 def self.puts(*args) new.puts(*args) end |
Instance Method Details
#ask_which_test_to_use(path, files) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/retest/prompt.rb', line 19 def ask_which_test_to_use(path, files) changed notify_observers(:question) = (files) output.puts(<<~QUESTION) We found few tests matching: #{path} #{(.keys)} Which file do you want to use? Enter the file number now: QUESTION output.print("> ") .values[input.gets.chomp.to_i] end |
#puts(*args) ⇒ Object
37 38 39 |
# File 'lib/retest/prompt.rb', line 37 def puts(*args) output.puts(*args) end |
#read_output ⇒ Object
41 42 43 |
# File 'lib/retest/prompt.rb', line 41 def read_output output.tap(&:rewind).read end |