Class: Byebug::PutLCommand

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

Overview

Evaluation, pretty printing and columnizing from byebug's prompt.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from EvalFunctions

#allowing_other_threads, #eval_with_setting, #run_with_binding

Methods inherited from Command

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

Methods included from StringFunctions

#camelize, #prettify

Methods included from FileFunctions

#get_line, #get_lines, #n_lines, #normalize

Methods included from ParseFunctions

#get_int, #parse_steps, #syntax_valid?

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject


172
173
174
175
176
177
178
# File 'lib/byebug/commands/eval.rb', line 172

def description
  prettify <<-EOD
    putl <expression>

    Evaluates <expression>, an array, and columnize its value.
  EOD
end

.namesObject


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

def names
  %w(putl)
end

Instance Method Details

#executeObject


151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/byebug/commands/eval.rb', line 151

def execute
  out = StringIO.new
  run_with_binding do |b|
    res = eval_with_setting(b, @match.post_match, Setting[:stack_on_error])

    if res.is_a?(Array)
      puts "#{columnize(res.map(&:to_s), Setting[:width])}"
    else
      PP.pp(res, out)
      puts out.string
    end
  end
rescue
  out.puts $ERROR_INFO.message
end

#regexpObject


147
148
149
# File 'lib/byebug/commands/eval.rb', line 147

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