Class: Byebug::Interface
- Inherits:
-
Object
- Object
- Byebug::Interface
- Includes:
- FileFunctions
- 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 FileFunctions
#get_line, #get_lines, #n_lines, #normalize
Constructor Details
Instance Attribute Details
#command_queue ⇒ Object
Returns the value of attribute command_queue.
14 15 16 |
# File 'lib/byebug/interface.rb', line 14 def command_queue @command_queue end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
15 16 17 |
# File 'lib/byebug/interface.rb', line 15 def error @error end |
#history ⇒ Object
Returns the value of attribute history.
14 15 16 |
# File 'lib/byebug/interface.rb', line 14 def history @history end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
15 16 17 |
# File 'lib/byebug/interface.rb', line 15 def input @input end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
15 16 17 |
# File 'lib/byebug/interface.rb', line 15 def output @output end |
Instance Method Details
#autorestore ⇒ Object
Restores history according to autosave
setting.
92 93 94 |
# File 'lib/byebug/interface.rb', line 92 def autorestore history.restore if Setting[:autosave] end |
#autosave ⇒ Object
Saves or clears history according to autosave
setting.
85 86 87 |
# File 'lib/byebug/interface.rb', line 85 def autosave Setting[:autosave] ? history.save : history.clear end |
#close ⇒ Object
79 80 |
# File 'lib/byebug/interface.rb', line 79 def close end |
#confirm(prompt) ⇒ Object
Confirms user introduced an affirmative response to the input stream.
75 76 77 |
# File 'lib/byebug/interface.rb', line 75 def confirm(prompt) readline(prompt) == 'y' end |
#errmsg(message) ⇒ Object
Prints an error message to the error stream.
57 58 59 |
# File 'lib/byebug/interface.rb', line 57 def errmsg() error.print("*** #{}\n") end |
#print(message) ⇒ Object
68 69 70 |
# File 'lib/byebug/interface.rb', line 68 def print() output.print() end |
#puts(message) ⇒ Object
Prints an output message to the output stream.
64 65 66 |
# File 'lib/byebug/interface.rb', line 64 def puts() output.puts() end |
#read_command(prompt) ⇒ Object
Pops a command from the input stream.
24 25 26 27 28 29 30 31 32 |
# File 'lib/byebug/interface.rb', line 24 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.
38 39 40 |
# File 'lib/byebug/interface.rb', line 38 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.
45 46 47 48 49 50 51 52 |
# File 'lib/byebug/interface.rb', line 45 def read_input(prompt, save_hist = true) line = readline(prompt) return unless line history.push(line) if save_hist split_commands(line) end |