Class: Byebug::PutlCommand

Inherits:
Command
  • Object
show all
Includes:
Helpers::EvalHelper, Columnize
Defined in:
lib/byebug/commands/putl.rb

Overview

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

Instance Method Summary collapse

Methods included from Helpers::EvalHelper

#allowing_other_threads, #eval_with_setting, #run_with_binding

Methods inherited from Command

#help, #initialize, #match, subcommands, to_name

Methods included from Helpers::StringHelper

#camelize, #prettify

Constructor Details

This class inherits a constructor from Byebug::Command

Instance Method Details

#descriptionObject



35
36
37
38
39
40
41
# File 'lib/byebug/commands/putl.rb', line 35

def description
  <<-EOD
    putl <expression>

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

#executeObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/byebug/commands/putl.rb', line 19

def execute
  out = StringIO.new
  run_with_binding do |b|
    res = eval_with_setting(b, @match[1], 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



15
16
17
# File 'lib/byebug/commands/putl.rb', line 15

def regexp
  /^\s* putl (?:\s+ (.+))? \s*$/x
end