Class: IRB::ExtendCommand::Ls

Inherits:
Nop show all
Defined in:
lib/irb/cmd/ls.rb

Instance Attribute Summary

Attributes inherited from Nop

#irb_context

Instance Method Summary collapse

Methods inherited from Nop

execute, #initialize, #irb

Constructor Details

This class inherits a constructor from IRB::ExtendCommand::Nop

Instance Method Details

#execute(*arg, grep: nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/irb/cmd/ls.rb', line 11

def execute(*arg, grep: nil)
  o = Output.new(grep: grep)

  obj    = arg.empty? ? irb_context.workspace.main : arg.first
  locals = arg.empty? ? irb_context.workspace.binding.local_variables : []
  klass  = (obj.class == Class || obj.class == Module ? obj : obj.class)

  o.dump("constants", obj.constants) if obj.respond_to?(:constants)
  o.dump("#{klass}.methods", obj.singleton_methods(false))
  o.dump("#{klass}#methods", klass.public_instance_methods(false))
  o.dump("instance variables", obj.instance_variables)
  o.dump("class variables", klass.class_variables)
  o.dump("locals", locals)
end