summaryrefslogtreecommitdiff
path: root/lib/pry/commands/ls/self_methods.rb
blob: d02c3e1a3d16e14845046806bdd6fe418aaa8886 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require 'pry/commands/ls/interrogatable'
require 'pry/commands/ls/methods_helper'

class Pry
  class Command::Ls < Pry::ClassCommand
    class SelfMethods < Pry::Command::Ls::Formatter
      include Pry::Command::Ls::Interrogatable
      include Pry::Command::Ls::MethodsHelper

      def initialize(interrogatee, no_user_opts, opts, _pry_)
        super(_pry_)
        @interrogatee = interrogatee
        @no_user_opts = no_user_opts
        @ppp_switch = opts[:ppp]
        @jruby_switch = opts['all-java']
      end

      def output_self
        methods = all_methods(true).select do |m|
          m.owner == @interrogatee && grep.regexp[m.name]
        end
        heading = "#{ Pry::WrappedModule.new(@interrogatee).method_prefix }methods"
        output_section(heading, format(methods))
      end

      private

      def correct_opts?
        @no_user_opts && interrogating_a_module?
      end

    end
  end
end