Class: Byebug::ScriptInterface
- Defined in:
- lib/byebug/interfaces/script_interface.rb
Overview
Interface class for command execution from script files.
Instance Attribute Summary
Attributes inherited from Interface
Instance Method Summary collapse
- #close ⇒ Object
- #confirm(_prompt) ⇒ Object
-
#initialize(file, out, verbose = false) ⇒ ScriptInterface
constructor
A new instance of ScriptInterface.
- #puts(message) ⇒ Object
- #read_command(_prompt) ⇒ Object
Methods inherited from Interface
Constructor Details
#initialize(file, out, verbose = false) ⇒ ScriptInterface
Returns a new instance of ScriptInterface.
6 7 8 9 10 |
# File 'lib/byebug/interfaces/script_interface.rb', line 6 def initialize(file, out, verbose = false) super() @file = file.respond_to?(:gets) ? file : open(file) @out, @verbose = out, verbose end |
Instance Method Details
#close ⇒ Object
29 30 31 |
# File 'lib/byebug/interfaces/script_interface.rb', line 29 def close @file.close end |
#confirm(_prompt) ⇒ Object
21 22 23 |
# File 'lib/byebug/interfaces/script_interface.rb', line 21 def confirm(_prompt) 'y' end |
#puts(message) ⇒ Object
25 26 27 |
# File 'lib/byebug/interfaces/script_interface.rb', line 25 def puts() @out.printf() end |
#read_command(_prompt) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/byebug/interfaces/script_interface.rb', line 12 def read_command(_prompt) while (result = @file.gets) puts "# #{result}" if @verbose next if result =~ /^\s*#/ next if result.strip.empty? return result.chomp end end |