Class: DebuggerXml::Ide::Interface
- Inherits:
-
Object
- Object
- DebuggerXml::Ide::Interface
- Defined in:
- lib/debugger_xml/ide/interface.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#command_queue ⇒ Object
Returns the value of attribute command_queue.
-
#histfile ⇒ Object
Returns the value of attribute histfile.
-
#history_length ⇒ Object
Returns the value of attribute history_length.
-
#history_save ⇒ Object
Returns the value of attribute history_save.
-
#restart_file ⇒ Object
Returns the value of attribute restart_file.
Instance Method Summary collapse
- #close ⇒ Object
- #confirm(prompt) ⇒ Object
- #errmsg(*args) ⇒ Object
- #finalize ⇒ Object
-
#initialize(socket) ⇒ Interface
constructor
A new instance of Interface.
-
#non_blocking_gets ⇒ Object
Workaround for JRuby issue jira.codehaus.org/browse/JRUBY-2063.
- #print(*args) ⇒ Object
- #print_debug(msg) ⇒ Object
- #puts(*args) ⇒ Object
- #read_command(*args) ⇒ Object
- #readline_support? ⇒ Boolean
Constructor Details
#initialize(socket) ⇒ Interface
Returns a new instance of Interface.
10 11 12 13 14 15 16 17 |
# File 'lib/debugger_xml/ide/interface.rb', line 10 def initialize(socket) @command_queue = [] @socket = socket @history_save = false @history_length = 256 @histfile = '' @restart_file = nil end |
Instance Attribute Details
#command_queue ⇒ Object
Returns the value of attribute command_queue.
4 5 6 |
# File 'lib/debugger_xml/ide/interface.rb', line 4 def command_queue @command_queue end |
#histfile ⇒ Object
Returns the value of attribute histfile.
5 6 7 |
# File 'lib/debugger_xml/ide/interface.rb', line 5 def histfile @histfile end |
#history_length ⇒ Object
Returns the value of attribute history_length.
7 8 9 |
# File 'lib/debugger_xml/ide/interface.rb', line 7 def history_length @history_length end |
#history_save ⇒ Object
Returns the value of attribute history_save.
6 7 8 |
# File 'lib/debugger_xml/ide/interface.rb', line 6 def history_save @history_save end |
#restart_file ⇒ Object
Returns the value of attribute restart_file.
8 9 10 |
# File 'lib/debugger_xml/ide/interface.rb', line 8 def restart_file @restart_file end |
Instance Method Details
#close ⇒ Object
19 20 21 22 |
# File 'lib/debugger_xml/ide/interface.rb', line 19 def close @socket.close rescue Exception end |
#confirm(prompt) ⇒ Object
32 33 34 |
# File 'lib/debugger_xml/ide/interface.rb', line 32 def confirm(prompt) true end |
#errmsg(*args) ⇒ Object
28 29 30 |
# File 'lib/debugger_xml/ide/interface.rb', line 28 def errmsg(*args) print(*args) end |
#finalize ⇒ Object
36 37 38 |
# File 'lib/debugger_xml/ide/interface.rb', line 36 def finalize close end |
#non_blocking_gets ⇒ Object
Workaround for JRuby issue jira.codehaus.org/browse/JRUBY-2063
41 42 43 44 45 46 47 |
# File 'lib/debugger_xml/ide/interface.rb', line 41 def non_blocking_gets loop do result, _, _ = IO.select([@socket], nil, nil, 0.2) next unless result return result[0].gets end end |
#print(*args) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/debugger_xml/ide/interface.rb', line 61 def print(*args) escaped_args = escape_input(args) value = escaped_args.first % escaped_args[1..-1] DebuggerXml.logger.puts("Going to print: #{value}") @socket.print(value) end |
#print_debug(msg) ⇒ Object
24 25 26 |
# File 'lib/debugger_xml/ide/interface.rb', line 24 def print_debug(msg) STDOUT.puts(msg) end |
#puts(*args) ⇒ Object
68 69 70 |
# File 'lib/debugger_xml/ide/interface.rb', line 68 def puts(*args) print(*args) end |
#read_command(*args) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/debugger_xml/ide/interface.rb', line 49 def read_command(*args) result = non_blocking_gets raise IOError unless result result.chomp.tap do |r| DebuggerXml.logger.puts("Read command: #{r}") end end |
#readline_support? ⇒ Boolean
57 58 59 |
# File 'lib/debugger_xml/ide/interface.rb', line 57 def readline_support? false end |