Sha256: 462f1a20b09713685bad2ac57a059e00836886a0ff1b797410b13ead2ff91533

Contents?: true

Size: 1.14 KB

Versions: 39

Compression:

Stored size: 1.14 KB

Contents

module Debugger
  class MethodCommand < Command # :nodoc:
    def regexp
      /^\s*m(?:ethod)?\s+(?:(i(:?nstance)?)\s)?/
    end

    def execute
      if @match[1]
        obj = debug_eval(@match.post_match)

        len = 0
        for v in obj.methods.sort
          len += v.size + 1
          if len > 70
            len = v.size + 1
            print "\n"
          end
          print "%s ", v
        end
        print "\n"
      else
        obj = debug_eval(@match.post_match)
        unless obj.kind_of? Module
          print "Should be Class/Module: %s\n", @match.post_match
        else
          len = 0
          for v in obj.instance_methods(false).sort
            len += v.size + 1
            if len > 70
              len = v.size + 1
              print "\n"
            end
            print "%s ", v
          end
          print "\n"
        end
      end
    end

    class << self
      def help_command
        'method'
      end

      def help(cmd)
        %{
          m[ethod] i[nstance] <obj>\tshow methods of object
          m[ethod] <class|module>\t\tshow instance methods of class or module
        }
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
ruby-debug-0.4.5-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.7.5-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.7.4-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.7.3-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.7.2-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.7.1-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.7-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.6.2-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.6.1-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.6-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.5.2-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.5.1-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.5-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.4.4-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.4.3-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.4.2-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.5 lib/ruby-debug/commands/method.rb
ruby-debug-0.5.3 lib/ruby-debug/commands/method.rb
ruby-debug-0.7.1 lib/ruby-debug/commands/method.rb
ruby-debug-0.6.2 lib/ruby-debug/commands/method.rb