Sha256: b8d69beefa9ed0144d41a141dc02ac55255969a34d78da119a0b1ba7897e0597

Contents?: true

Size: 902 Bytes

Versions: 2

Compression:

Stored size: 902 Bytes

Contents

require 'English'
require 'byebug/command'
require 'byebug/helpers/eval'

module Byebug
  #
  # Evaluation of expressions from byebug's prompt.
  #
  class EvalCommand < Command
    include Helpers::EvalHelper

    def match(input)
      @input = input
      super
    end

    def regexp
      /^\s* e(?:val)? \s+/x
    end

    def execute
      expr = @match ? @match.post_match : @input
      run_with_binding do |b|
        res = eval_with_setting(b, expr, Setting[:stack_on_error])

        print pr('eval.result', expr: expr, result: res.inspect)
      end
    rescue
      puts "#{$ERROR_INFO.class} Exception: #{$ERROR_INFO.message}"
    end

    def description
      <<-EOD
        e[val] <expression>

        Evaluates <expression> and prints its value.

        * NOTE - unknown input is automatically evaluated, to turn this off use
        'set noautoeval'.
      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/eval.rb
byebug-5.0.0 lib/byebug/commands/eval.rb