Class: Pry::Command::Ls::LocalVars

Inherits:
Formatter show all
Defined in:
lib/pry/commands/ls/local_vars.rb

Instance Attribute Summary

Attributes inherited from Formatter

#_pry_

Instance Method Summary collapse

Methods inherited from Formatter

#write_out

Constructor Details

#initialize(opts, _pry_) ⇒ LocalVars

Returns a new instance of LocalVars.



4
5
6
7
8
# File 'lib/pry/commands/ls/local_vars.rb', line 4

def initialize(opts, _pry_)
  super(_pry_)
  @default_switch = opts[:locals]
  @sticky_locals = _pry_.sticky_locals
end

Instance Method Details

#output_selfObject



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

def output_self
  name_value_pairs = @target.eval('local_variables').reject { |e|
    @sticky_locals.keys.include?(e.to_sym)
  }.map { |name|
    [name, (@target.eval(name.to_s))]
  }
  format(name_value_pairs).join('')
end