Module: Pry::Command::Ls::MethodsHelper

Includes:
JRubyHacks
Included in:
Methods, SelfMethods
Defined in:
lib/pry/commands/ls/methods_helper.rb

Instance Method Summary collapse

Methods included from JRubyHacks

#rubbishness, #trim_jruby_aliases

Instance Method Details

#all_methods(instance_methods = false) ⇒ Object (private)

Get all the methods that we'll want to output.


12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pry/commands/ls/methods_helper.rb', line 12

def all_methods(instance_methods = false)
  methods = if instance_methods || @instance_methods_switch
              Pry::Method.all_from_class(@interrogatee)
            else
              Pry::Method.all_from_obj(@interrogatee)
            end

  if Pry::Helpers::Platform.jruby? && !@jruby_switch
    methods = trim_jruby_aliases(methods)
  end

  methods.select { |method| @ppp_switch || method.visibility == :public }
end

#format(methods) ⇒ Object (private)


34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/pry/commands/ls/methods_helper.rb', line 34

def format(methods)
  methods.sort_by(&:name).map do |method|
    if method.name == 'method_missing'
      color(:method_missing, 'method_missing')
    elsif method.visibility == :private
      color(:private_method, method.name)
    elsif method.visibility == :protected
      color(:protected_method, method.name)
    else
      color(:public_method, method.name)
    end
  end
end

#resolution_orderObject (private)


26
27
28
29
30
31
32
# File 'lib/pry/commands/ls/methods_helper.rb', line 26

def resolution_order
  if @instance_methods_switch
    Pry::Method.instance_resolution_order(@interrogatee)
  else
    Pry::Method.resolution_order(@interrogatee)
  end
end