Class: Debugger::Command

Inherits:
Object
  • 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.



68
69
70
# File 'lib/ruby-debug-ide/command.rb', line 68

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object (protected)



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

def method_missing(meth, *args, &block)
  if @printer.respond_to? meth
    @printer.send meth, *args, &block
  else
    super
  end
end

Class Method Details

.commandsObject



23
24
25
# File 'lib/ruby-debug-ide/command.rb', line 23

def commands
  @commands ||= []
end

.inherited(klass) ⇒ Object



34
35
36
37
38
39
# File 'lib/ruby-debug-ide/command.rb', line 34

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

.load_commandsObject



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

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



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/ruby-debug-ide/command.rb', line 51

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



63
64
65
# File 'lib/ruby-debug-ide/command.rb', line 63

def options
  @options ||= {}
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



11
12
13
14
15
16
17
18
19
20
# File 'lib/ruby-debug-ide/command.rb', line 11

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



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

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