class Pry::Command::Ls::Globals

Constants

BUILTIN_GLOBALS

Taken from “puts global_variables.inspect”.

PSEUDO_GLOBALS

`$SAFE` and `$?` are thread-local, the exception stuff only works in a rescue clause, everything else is basically a local variable with a `$` in its name.

Public Class Methods

new(opts, pry_instance) click to toggle source
Calls superclass method Pry::Command::Ls::Formatter::new
# File lib/pry/commands/ls/globals.rb, line 24
def initialize(opts, pry_instance)
  super(pry_instance)
  @default_switch = opts[:globals]
end

Public Instance Methods

output_self() click to toggle source
# File lib/pry/commands/ls/globals.rb, line 29
def output_self
  variables = format(@target.eval('global_variables'))
  output_section('global variables', grep.regexp[variables])
end

Private Instance Methods

format(globals) click to toggle source
# File lib/pry/commands/ls/globals.rb, line 36
def format(globals)
  globals.map(&:to_s).sort_by(&:downcase).map do |name|
    if PSEUDO_GLOBALS.include?(name)
      color(:pseudo_global, name)
    elsif BUILTIN_GLOBALS.include?(name)
      color(:builtin_global, name)
    else
      color(:global_var, name)
    end
  end
end