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

#errmsg, #escape, #format

Constructor Details

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

Returns a new instance of ScriptInterface.



177
178
179
180
181
182
183
184
185
186
# File 'lib/byebug/interface.rb', line 177

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.



174
175
176
# File 'lib/byebug/interface.rb', line 174

def command_queue
  @command_queue
end

#histfileObject

Returns the value of attribute histfile.



174
175
176
# File 'lib/byebug/interface.rb', line 174

def histfile
  @histfile
end

#history_lengthObject

Returns the value of attribute history_length.



174
175
176
# File 'lib/byebug/interface.rb', line 174

def history_length
  @history_length
end

#history_saveObject

Returns the value of attribute history_save.



174
175
176
# File 'lib/byebug/interface.rb', line 174

def history_save
  @history_save
end

#restart_fileObject

Returns the value of attribute restart_file.



175
176
177
# File 'lib/byebug/interface.rb', line 175

def restart_file
  @restart_file
end

Instance Method Details

#closeObject



214
215
216
# File 'lib/byebug/interface.rb', line 214

def close
  @file.close
end

#confirm(prompt) ⇒ Object



206
207
208
# File 'lib/byebug/interface.rb', line 206

def confirm(prompt)
  'y'
end

#finalizeObject



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

def finalize
end


210
211
212
# File 'lib/byebug/interface.rb', line 210

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

#read_command(prompt) ⇒ Object

Raises:

  • (IOError)


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

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)


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

def readline_support?
  false
end