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
#command_queue, #error, #history, #input, #output
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(file, verbose = false) ⇒ ScriptInterface
constructor
A new instance of ScriptInterface.
- #read_command(prompt) ⇒ Object
- #readline ⇒ Object
Methods inherited from Interface
#autorestore, #autosave, #confirm, #errmsg, #last_if_empty, #prepare_input, #print, #puts, #read_file, #read_input
Methods included from Helpers::FileHelper
#get_line, #get_lines, #n_lines, #normalize, #shortpath, #virtual_file?
Constructor Details
#initialize(file, verbose = false) ⇒ ScriptInterface
Returns a new instance of ScriptInterface.
8 9 10 11 12 13 14 |
# File 'lib/byebug/interfaces/script_interface.rb', line 8 def initialize(file, verbose = false) super() @verbose = verbose @input = File.open(file) @output = verbose ? $stdout : StringIO.new @error = $stderr end |
Instance Method Details
#close ⇒ Object
20 21 22 |
# File 'lib/byebug/interfaces/script_interface.rb', line 20 def close input.close end |
#read_command(prompt) ⇒ Object
16 17 18 |
# File 'lib/byebug/interfaces/script_interface.rb', line 16 def read_command(prompt) readline(prompt, false) end |
#readline ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/byebug/interfaces/script_interface.rb', line 24 def readline(*) while (result = input.gets) output.puts "+ #{result}" if @verbose next if /^\s*#/.match?(result) return result.chomp end end |