Class: Byebug::Interface
- Inherits:
-
Object
- Object
- Byebug::Interface
- Includes:
- Helpers::FileHelper
- Defined in:
- lib/byebug/interface.rb
Overview
Main Interface class
Contains common functionality to all implemented interfaces.
Direct Known Subclasses
LocalInterface, RemoteInterface, ScriptInterface, TestInterface
Instance Attribute Summary collapse
-
#command_queue ⇒ Object
Returns the value of attribute command_queue.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#history ⇒ Object
Returns the value of attribute history.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
-
#autorestore ⇒ Object
Restores history according to
autosave
setting. -
#autosave ⇒ Object
Saves or clears history according to
autosave
setting. - #close ⇒ Object
-
#confirm(prompt) ⇒ Object
Confirms user introduced an affirmative response to the input stream.
-
#errmsg(message) ⇒ Object
Prints an error message to the error stream.
-
#initialize ⇒ Interface
constructor
A new instance of Interface.
- #print(message) ⇒ Object
-
#puts(message) ⇒ Object
Prints an output message to the output stream.
-
#read_command(prompt) ⇒ Object
Pops a command from the input stream.
-
#read_file(filename) ⇒ Object
Pushes lines in
filename
to the command queue. -
#read_input(prompt, save_hist = true) ⇒ Object
Reads a new line from the interface’s input stream.
Methods included from Helpers::FileHelper
#get_line, #get_lines, #n_lines, #normalize
Constructor Details
Instance Attribute Details
#command_queue ⇒ Object
Returns the value of attribute command_queue.
16 17 18 |
# File 'lib/byebug/interface.rb', line 16 def command_queue @command_queue end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
17 18 19 |
# File 'lib/byebug/interface.rb', line 17 def error @error end |
#history ⇒ Object
Returns the value of attribute history.
16 17 18 |
# File 'lib/byebug/interface.rb', line 16 def history @history end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
17 18 19 |
# File 'lib/byebug/interface.rb', line 17 def input @input end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
17 18 19 |
# File 'lib/byebug/interface.rb', line 17 def output @output end |
Instance Method Details
#autorestore ⇒ Object
Restores history according to autosave
setting.
94 95 96 |
# File 'lib/byebug/interface.rb', line 94 def autorestore history.restore if Setting[:autosave] end |
#autosave ⇒ Object
Saves or clears history according to autosave
setting.
87 88 89 |
# File 'lib/byebug/interface.rb', line 87 def autosave Setting[:autosave] ? history.save : history.clear end |
#close ⇒ Object
81 82 |
# File 'lib/byebug/interface.rb', line 81 def close end |
#confirm(prompt) ⇒ Object
Confirms user introduced an affirmative response to the input stream.
77 78 79 |
# File 'lib/byebug/interface.rb', line 77 def confirm(prompt) readline(prompt) == 'y' end |
#errmsg(message) ⇒ Object
Prints an error message to the error stream.
59 60 61 |
# File 'lib/byebug/interface.rb', line 59 def errmsg() error.print("*** #{}\n") end |
#print(message) ⇒ Object
70 71 72 |
# File 'lib/byebug/interface.rb', line 70 def print() output.print() end |
#puts(message) ⇒ Object
Prints an output message to the output stream.
66 67 68 |
# File 'lib/byebug/interface.rb', line 66 def puts() output.puts() end |
#read_command(prompt) ⇒ Object
Pops a command from the input stream.
27 28 29 30 31 32 33 34 35 |
# File 'lib/byebug/interface.rb', line 27 def read_command(prompt) return command_queue.shift unless command_queue.empty? cmds = read_input(prompt) return unless cmds command_queue.concat(cmds) command_queue.shift end |
#read_file(filename) ⇒ Object
Pushes lines in filename
to the command queue.
40 41 42 |
# File 'lib/byebug/interface.rb', line 40 def read_file(filename) command_queue.concat(get_lines(filename)) end |
#read_input(prompt, save_hist = true) ⇒ Object
Reads a new line from the interface’s input stream.
47 48 49 50 51 52 53 54 |
# File 'lib/byebug/interface.rb', line 47 def read_input(prompt, save_hist = true) line = readline(prompt) return unless line history.push(line) if save_hist split_commands(line) end |