Class: Byebug::PSCommand

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



157
158
159
160
161
# File 'lib/byebug/commands/eval.rb', line 157

def description
  %{ps expression

    Evaluate expression, an array, sort and columnize its value}
end

.namesObject



153
154
155
# File 'lib/byebug/commands/eval.rb', line 153

def names
  %w(ps)
end

Instance Method Details

#executeObject



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/byebug/commands/eval.rb', line 132

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}
      print "#{columnize(vals.sort!, Setting[:width])}\n"
    else
      PP.pp(vals, out)
      print out.string
    end
  end
rescue
  out.puts $!.message
end

#regexpObject



128
129
130
# File 'lib/byebug/commands/eval.rb', line 128

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