Class: Byebug::ScriptInterface

Inherits:
Interface show all
Defined in:
lib/byebug/interfaces/script_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.



6
7
8
9
10
11
12
13
14
15
# File 'lib/byebug/interfaces/script_interface.rb', line 6

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.



3
4
5
# File 'lib/byebug/interfaces/script_interface.rb', line 3

def command_queue
  @command_queue
end

#histfileObject

Returns the value of attribute histfile.



3
4
5
# File 'lib/byebug/interfaces/script_interface.rb', line 3

def histfile
  @histfile
end

#history_lengthObject

Returns the value of attribute history_length.



3
4
5
# File 'lib/byebug/interfaces/script_interface.rb', line 3

def history_length
  @history_length
end

#history_saveObject

Returns the value of attribute history_save.



3
4
5
# File 'lib/byebug/interfaces/script_interface.rb', line 3

def history_save
  @history_save
end

#restart_fileObject

Returns the value of attribute restart_file.



4
5
6
# File 'lib/byebug/interfaces/script_interface.rb', line 4

def restart_file
  @restart_file
end

Instance Method Details

#closeObject



41
42
43
# File 'lib/byebug/interfaces/script_interface.rb', line 41

def close
  @file.close
end

#confirm(prompt) ⇒ Object



33
34
35
# File 'lib/byebug/interfaces/script_interface.rb', line 33

def confirm(prompt)
  'y'
end

#finalizeObject



17
18
# File 'lib/byebug/interfaces/script_interface.rb', line 17

def finalize
end


37
38
39
# File 'lib/byebug/interfaces/script_interface.rb', line 37

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

#read_command(prompt) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/byebug/interfaces/script_interface.rb', line 20

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

#readline_support?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/byebug/interfaces/script_interface.rb', line 29

def readline_support?
  false
end