Class: Byebug::PSCommand

Inherits:
Command show all
Includes:
EvalFunctions, Columnize
Defined in:
lib/byebug/commands/eval.rb

Constant Summary

Constants inherited from Command

Command::DEF_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from EvalFunctions

#run_with_binding

Methods inherited from Command

commands, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match, method_missing, options, register_setting_get, register_setting_set, register_setting_var, settings, settings_map

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



167
168
169
170
171
# File 'lib/byebug/commands/eval.rb', line 167

def description
  %{
    ps expression\tevaluate expression, an array, sort and columnize its value
  }
end

.namesObject



163
164
165
# File 'lib/byebug/commands/eval.rb', line 163

def names
  %w(ps)
end

Instance Method Details

#executeObject



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/byebug/commands/eval.rb', line 146

def execute
  out = StringIO.new
  run_with_binding do |b|
    vals = debug_eval(@match.post_match, b)
    if vals.is_a?(Array)
      vals = vals.map{|item| item.to_s}
      print "#{columnize(vals.sort!, Command.settings[:width])}\n"
    else
      PP.pp(vals, out)
      print out.string
    end
  end
rescue
  out.puts $!.message
end

#regexpObject



142
143
144
# File 'lib/byebug/commands/eval.rb', line 142

def regexp
  /^\s*ps\s+/
end