Class: Byebug::PSCommand
- Inherits:
-
Command
show all
- Includes:
- Columnize
- Defined in:
- lib/byebug/commands/eval.rb
Overview
Evaluation, pretty printing, columnizing and sorting from byebug’s prompt
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match
Class Method Details
.description ⇒ Object
176
177
178
179
180
|
# File 'lib/byebug/commands/eval.rb', line 176
def description
%(ps <expression>
Evaluates <expression>, an array, sort and columnize its value.)
end
|
.names ⇒ Object
172
173
174
|
# File 'lib/byebug/commands/eval.rb', line 172
def names
%w(ps)
end
|
Instance Method Details
#execute ⇒ Object
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
# File 'lib/byebug/commands/eval.rb', line 151
def execute
out = StringIO.new
run_with_binding do |b|
if Setting[:stack_on_error]
vals = bb_eval(@match.post_match, b)
else
vals = bb_warning_eval(@match.post_match, b)
end
if vals.is_a?(Array)
vals = vals.map { |item| item.to_s }
puts "#{columnize(vals.sort!, Setting[:width])}"
else
PP.pp(vals, out)
puts out.string
end
end
rescue
out.puts $ERROR_INFO.message
end
|
#regexp ⇒ Object
147
148
149
|
# File 'lib/byebug/commands/eval.rb', line 147
def regexp
/^\s* ps\s+/x
end
|