Sha256: 1f5c3878948b776246f945ae2243ec3a86b6a449189b3111ebf436d2e74cdcd8

Contents?: true

Size: 902 Bytes

Versions: 21

Compression:

Stored size: 902 Bytes

Contents

class Pry
  class Command::WatchExpression
    class Expression
      attr_reader :target, :source, :value, :previous_value, :_pry_

      def initialize(_pry_, target, source)
        @_pry_ = _pry_
        @target = target
        @source = source.strip
      end

      def eval!
        @previous_value = @value
        @value = Pry::ColorPrinter.pp(target_eval(target, source), "")
      end

      def to_s
        "#{Code.new(source).strip} => #{value}"
      end

      # Has the value of the expression changed?
      #
      # We use the pretty-printed string represenation to detect differences
      # as this avoids problems with dup (causes too many differences) and == (causes too few)
      def changed?
        (value != previous_value)
      end

      private

      def target_eval(target, source)
        target.eval(source)
      rescue => e
        e
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
whos_dated_who-0.1.0 vendor/bundle/gems/pry-0.10.0/lib/pry/commands/watch_expression/expression.rb
whos_dated_who-0.0.1 vendor/bundle/gems/pry-0.10.0/lib/pry/commands/watch_expression/expression.rb
pry-0.10.0 lib/pry/commands/watch_expression/expression.rb
pry-0.10.0-i386-mswin32 lib/pry/commands/watch_expression/expression.rb
pry-0.10.0-i386-mingw32 lib/pry/commands/watch_expression/expression.rb
pry-0.10.0-x64-mingw32 lib/pry/commands/watch_expression/expression.rb
pry-0.10.0-java lib/pry/commands/watch_expression/expression.rb
pry-0.10.0.rc1 lib/pry/commands/watch_expression/expression.rb
pry-0.10.0.rc1-i386-mswin32 lib/pry/commands/watch_expression/expression.rb
pry-0.10.0.rc1-i386-mingw32 lib/pry/commands/watch_expression/expression.rb
pry-0.10.0.rc1-x64-mingw32 lib/pry/commands/watch_expression/expression.rb
pry-0.10.0.rc1-java lib/pry/commands/watch_expression/expression.rb
pry-0.10.0.pre4 lib/pry/commands/watch_expression/expression.rb
pry-0.10.0.pre4-i386-mswin32 lib/pry/commands/watch_expression/expression.rb
pry-0.10.0.pre4-i386-mingw32 lib/pry/commands/watch_expression/expression.rb
pry-0.10.0.pre4-x64-mingw32 lib/pry/commands/watch_expression/expression.rb
pry-0.10.0.pre4-java lib/pry/commands/watch_expression/expression.rb
pry-0.10.0.pre3 lib/pry/commands/watch_expression/expression.rb
pry-0.10.0.pre3-i386-mswin32 lib/pry/commands/watch_expression/expression.rb
pry-0.10.0.pre3-i386-mingw32 lib/pry/commands/watch_expression/expression.rb