Sha256: ee39f249e8a7b9d9b93593397aba7d63dca49d4b7b2a5a6eb3a230fe7b8b756e

Contents?: true

Size: 875 Bytes

Versions: 2

Compression:

Stored size: 875 Bytes

Contents

require 'pp'
require 'byebug/command'
require 'byebug/helpers/eval'

module Byebug
  #
  # Evaluation, pretty printing and columnizing from byebug's prompt.
  #
  class PutlCommand < Command
    include Helpers::EvalHelper
    include Columnize

    self.allow_in_control = true

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

    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

    def description
      <<-EOD
        putl <expression>

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

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/byebug-5.0.0/lib/byebug/commands/putl.rb
byebug-5.0.0 lib/byebug/commands/putl.rb