Class: Debugger::Command

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

Overview

:nodoc:

Constant Summary collapse

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state) ⇒ Command

Returns a new instance of Command.



47
48
49
# File 'lib/ruby-debug/command.rb', line 47

def initialize(state)
  @state = state
end

Class Method Details

.commandsObject



4
5
6
# File 'lib/ruby-debug/command.rb', line 4

def commands
  @commands ||= []
end

.inherited(klass) ⇒ Object



16
17
18
19
20
21
# File 'lib/ruby-debug/command.rb', line 16

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

.load_commandsObject



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

def load_commands
  dir = File.dirname(__FILE__)
  Dir[File.join(dir, 'commands', '*')].each do |file|
    require file if file =~ /\.rb$/
  end
end

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



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ruby-debug/command.rb', line 30

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



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

def options
  @options ||= {}
end

Instance Method Details

#match(input) ⇒ Object



51
52
53
# File 'lib/ruby-debug/command.rb', line 51

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