Sha256: db31d0e6c419d10ba0d6a707905a560ad23a1e67f5b27b4fdae40b9c2edfe984

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 KB

Contents

module Debugger
  class MethodCommand < Command
    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

6 entries across 6 versions & 1 rubygems

Version Path
ruby-debug-0.4.1-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.4-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.3-mswin32 lib/ruby-debug/commands/method.rb
ruby-debug-0.3 lib/ruby-debug/commands/method.rb
ruby-debug-0.4 lib/ruby-debug/commands/method.rb
ruby-debug-0.4.1 lib/ruby-debug/commands/method.rb