Class: Pry::Command::Ls::LsEntity

Inherits:
Object
  • Object
show all
Defined in:
lib/pry/commands/ls/ls_entity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ LsEntity

Returns a new instance of LsEntity


9
10
11
12
13
14
15
16
# File 'lib/pry/commands/ls/ls_entity.rb', line 9

def initialize(opts)
  @interrogatee = opts[:interrogatee]
  @no_user_opts = opts[:no_user_opts]
  @opts = opts[:opts]
  @args = opts[:args]
  @grep = Grep.new(Regexp.new(opts[:opts][:G] || '.'))
  @pry_instance = opts.delete(:pry_instance)
end

Instance Attribute Details

#pry_instanceObject (readonly)

Returns the value of attribute pry_instance


7
8
9
# File 'lib/pry/commands/ls/ls_entity.rb', line 7

def pry_instance
  @pry_instance
end

Instance Method Details

#constantsObject (private)


32
33
34
# File 'lib/pry/commands/ls/ls_entity.rb', line 32

def constants
  grep Constants.new(@interrogatee, @no_user_opts, @opts, pry_instance)
end

#entitiesObject (private)


56
57
58
59
60
61
# File 'lib/pry/commands/ls/ls_entity.rb', line 56

def entities
  [
    globals, constants, methods, self_methods, instance_vars, local_names,
    local_vars
  ]
end

#entities_tableObject


18
19
20
# File 'lib/pry/commands/ls/ls_entity.rb', line 18

def entities_table
  entities.map(&:write_out).select { |o| o }.join('')
end

#globalsObject (private)


28
29
30
# File 'lib/pry/commands/ls/ls_entity.rb', line 28

def globals
  grep Globals.new(@opts, pry_instance)
end

#grep(entity) ⇒ Object (private)


24
25
26
# File 'lib/pry/commands/ls/ls_entity.rb', line 24

def grep(entity)
  entity.tap { |o| o.grep = @grep }
end

#instance_varsObject (private)


44
45
46
# File 'lib/pry/commands/ls/ls_entity.rb', line 44

def instance_vars
  grep InstanceVars.new(@interrogatee, @no_user_opts, @opts, pry_instance)
end

#local_namesObject (private)


48
49
50
# File 'lib/pry/commands/ls/ls_entity.rb', line 48

def local_names
  grep LocalNames.new(@no_user_opts, @args, pry_instance)
end

#local_varsObject (private)


52
53
54
# File 'lib/pry/commands/ls/ls_entity.rb', line 52

def local_vars
  LocalVars.new(@opts, pry_instance)
end

#methodsObject (private)


36
37
38
# File 'lib/pry/commands/ls/ls_entity.rb', line 36

def methods
  grep(Methods.new(@interrogatee, @no_user_opts, @opts, pry_instance))
end

#self_methodsObject (private)


40
41
42
# File 'lib/pry/commands/ls/ls_entity.rb', line 40

def self_methods
  grep SelfMethods.new(@interrogatee, @no_user_opts, @opts, pry_instance)
end