Class: Debugger::Command

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/ruby-debug-ide/command.rb

Overview

:nodoc:

Defined Under Namespace

Classes: SubcmdStruct

Constant Summary collapse

DEF_OPTIONS =
{
  :event => true, 
  :control => false, 
  :unknown => false,
  :need_context => false,
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state, printer) ⇒ Command

Returns a new instance of Command.



86
87
88
89
# File 'lib/ruby-debug-ide/command.rb', line 86

def initialize(state, printer)
  @state, @printer = state, printer
  super @printer
end

Class Method Details

.commandsObject



31
32
33
# File 'lib/ruby-debug-ide/command.rb', line 31

def commands
  @commands ||= []
end

.file_filter_supported?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/ruby-debug-ide/command.rb', line 81

def file_filter_supported?
  defined?(Debugger.file_filter)
end

.inherited(klass) ⇒ Object



42
43
44
45
46
47
# File 'lib/ruby-debug-ide/command.rb', line 42

def inherited(klass)
  DEF_OPTIONS.each do |o, v|
    klass.options[o] = v if klass.options[o].nil?
  end
  commands << klass
end

.load_commandsObject



49
50
51
52
53
54
55
56
57
# File 'lib/ruby-debug-ide/command.rb', line 49

def load_commands
  dir = File.dirname(__FILE__)
  Dir[File.join(dir, 'commands', '*')].each do |file|
    require file if file =~ /\.rb$/
  end
  Debugger.constants.grep(/Functions$/).map { |name| Debugger.const_get(name) }.each do |mod|
    include mod
  end
end

.method_missing(meth, *args, &block) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ruby-debug-ide/command.rb', line 59

def method_missing(meth, *args, &block)
  if meth.to_s =~ /^(.+?)=$/
    @options[$1.intern] = args.first
  else
    if @options.has_key?(meth)
      @options[meth]
    else
      super
    end
  end
end

.optionsObject



71
72
73
# File 'lib/ruby-debug-ide/command.rb', line 71

def options
  @options ||= {}
end

.unescape_incoming(str) ⇒ Object



75
76
77
78
79
# File 'lib/ruby-debug-ide/command.rb', line 75

def unescape_incoming(str)
  str.gsub(/((?:^|[^\\])(?:\\\\)*)((?:\\n)+)/) do |_|
    $1 + "\n" * ($2.size / 2)
  end.gsub(/\\\\/, '\\')
end

Instance Method Details

#find(subcmds, param) ⇒ Object

Find param in subcmds. param id downcased and can be abbreviated to the minimum length listed in the subcommands



19
20
21
22
23
24
25
26
27
28
# File 'lib/ruby-debug-ide/command.rb', line 19

def find(subcmds, param)
  param.downcase!
  for try_subcmd in subcmds do
    if (param.size >= try_subcmd.min) and
        (try_subcmd.name[0..param.size-1] == param)
      return try_subcmd
    end
  end
  return nil
end

#match(input) ⇒ Object



91
92
93
# File 'lib/ruby-debug-ide/command.rb', line 91

def match(input)
  @match = regexp.match(input)
end