Class: Byebug::ScriptInterface

Inherits:
Interface show all
Defined in:
lib/byebug/interface.rb

Instance Attribute Summary collapse

Attributes inherited from Interface

#have_readline

Instance Method Summary collapse

Methods inherited from Interface

#afmt, #aprint, #errmsg

Constructor Details

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

Returns a new instance of ScriptInterface.



192
193
194
195
196
197
198
199
200
201
# File 'lib/byebug/interface.rb', line 192

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
  @histfile = ''
end

Instance Attribute Details

#command_queueObject

Returns the value of attribute command_queue.



189
190
191
# File 'lib/byebug/interface.rb', line 189

def command_queue
  @command_queue
end

#histfileObject

Returns the value of attribute histfile.



189
190
191
# File 'lib/byebug/interface.rb', line 189

def histfile
  @histfile
end

#history_lengthObject

Returns the value of attribute history_length.



189
190
191
# File 'lib/byebug/interface.rb', line 189

def history_length
  @history_length
end

#history_saveObject

Returns the value of attribute history_save.



189
190
191
# File 'lib/byebug/interface.rb', line 189

def history_save
  @history_save
end

#restart_fileObject

Returns the value of attribute restart_file.



190
191
192
# File 'lib/byebug/interface.rb', line 190

def restart_file
  @restart_file
end

Instance Method Details

#closeObject



229
230
231
# File 'lib/byebug/interface.rb', line 229

def close
  @file.close
end

#confirm(prompt) ⇒ Object



221
222
223
# File 'lib/byebug/interface.rb', line 221

def confirm(prompt)
  'y'
end

#finalizeObject



203
204
# File 'lib/byebug/interface.rb', line 203

def finalize
end


225
226
227
# File 'lib/byebug/interface.rb', line 225

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

#read_command(prompt) ⇒ Object

Raises:

  • (IOError)


206
207
208
209
210
211
212
213
214
215
# File 'lib/byebug/interface.rb', line 206

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)


217
218
219
# File 'lib/byebug/interface.rb', line 217

def readline_support?
  false
end