Class: Debugger::ScriptInterface

Inherits:
Interface show all
Defined in:
lib/ruby-debug/interface.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Attributes inherited from Interface

#have_readline

Instance Method Summary collapse

Methods inherited from Interface

#afmt, #aprint, #errmsg, #print_debug

Constructor Details

#initialize(file, out, verbose = false) ⇒ ScriptInterface

Returns a new instance of ScriptInterface.



203
204
205
206
207
208
209
210
211
212
# File 'lib/ruby-debug/interface.rb', line 203

def initialize(file, out, verbose=false)
  super()
  @command_queue = []
  @file = file.respond_to?(:gets) ? file : open(file)
  @out = out
  @verbose = verbose
  @history_save = false
  @history_length = 256  # take gdb default
  @histfile = ''
end

Instance Attribute Details

#command_queueObject

Returns the value of attribute command_queue.



198
199
200
# File 'lib/ruby-debug/interface.rb', line 198

def command_queue
  @command_queue
end

#histfileObject

Returns the value of attribute histfile.



199
200
201
# File 'lib/ruby-debug/interface.rb', line 199

def histfile
  @histfile
end

#history_lengthObject

Returns the value of attribute history_length.



201
202
203
# File 'lib/ruby-debug/interface.rb', line 201

def history_length
  @history_length
end

#history_saveObject

Returns the value of attribute history_save.



200
201
202
# File 'lib/ruby-debug/interface.rb', line 200

def history_save
  @history_save
end

#restart_fileObject

Returns the value of attribute restart_file.



202
203
204
# File 'lib/ruby-debug/interface.rb', line 202

def restart_file
  @restart_file
end

Instance Method Details

#closeObject



240
241
242
# File 'lib/ruby-debug/interface.rb', line 240

def close
  @file.close
end

#confirm(prompt) ⇒ Object



232
233
234
# File 'lib/ruby-debug/interface.rb', line 232

def confirm(prompt)
  'y'
end

#finalizeObject



214
215
# File 'lib/ruby-debug/interface.rb', line 214

def finalize
end


236
237
238
# File 'lib/ruby-debug/interface.rb', line 236

def print(*args)
  @out.printf(*escape_input(args))
end

#read_command(prompt) ⇒ Object

Raises:

  • (IOError)


217
218
219
220
221
222
223
224
225
226
# File 'lib/ruby-debug/interface.rb', line 217

def read_command(prompt)
  while result = @file.gets
    puts "# #{result}" if @verbose
    next if result =~ /^\s*#/
    next if result.strip.empty?
    break
  end
  raise IOError unless result
  result.chomp!
end

#readline_support?Boolean

Returns:

  • (Boolean)


228
229
230
# File 'lib/ruby-debug/interface.rb', line 228

def readline_support?
  false
end