Class: Byebug::PutLCommand

Inherits:
Command
  • Object
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



116
117
118
119
120
# File 'lib/byebug/commands/eval.rb', line 116

def description
  %{putl expression

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

.namesObject



112
113
114
# File 'lib/byebug/commands/eval.rb', line 112

def names
  %w(putl)
end

Instance Method Details

#executeObject



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/byebug/commands/eval.rb', line 91

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

#regexpObject



87
88
89
# File 'lib/byebug/commands/eval.rb', line 87

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