Sha256: d4121a8b0ba20b8bdc0d74edc862bdf448e479841284112e9ebd3eaa5caffdbf

Contents?: true

Size: 987 Bytes

Versions: 6

Compression:

Stored size: 987 Bytes

Contents

module Byebug
  #
  # Show methods of specific classes/modules/objects.
  #
  class MethodCommand < Command
    include Columnize

    def regexp
      /^\s* m(?:ethod)? \s+ (i(:?nstance)?\s+)?/x
    end

    def execute
      obj = bb_eval(@match.post_match)
      if @match[1]
        puts "#{columnize(obj.methods.sort, Setting[:width])}"
      elsif !obj.is_a?(Module)
        puts "Should be Class/Module: #{@match.post_match}"
      else
        puts "#{columnize(obj.instance_methods(false).sort, Setting[:width])}"
      end
    end

    class << self
      def names
        %w(method)
      end

      def description
        %{m[ethod] (i[nstance][ <obj>]|<class|module>)

          When invoked with "instance", shows instance methods of the object
          specified as argument or of self no object was specified.

          When invoked only with a class or module, shows class methods of the
          class or module specified as argument.}
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
byebug-3.5.1 lib/byebug/commands/method.rb
byebug-3.5.0 lib/byebug/commands/method.rb
byebug-3.4.2 lib/byebug/commands/method.rb
byebug-3.4.1 lib/byebug/commands/method.rb
byebug-3.4.0 lib/byebug/commands/method.rb
byebug-3.3.0 lib/byebug/commands/method.rb