# File lib/pry/commands/watch_expression/expression.rb, line 6 def initialize(_pry_, target, source) @_pry_ = _pry_ @target = target @source = Code.new(source).strip 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)
# File lib/pry/commands/watch_expression/expression.rb, line 25 def changed? (value != previous_value) end
# File lib/pry/commands/watch_expression/expression.rb, line 12 def eval! @previous_value = @value @value = Pry::ColorPrinter.pp(target_eval(target, source), "") end
# File lib/pry/commands/watch_expression/expression.rb, line 17 def to_s "#{Code.new(source).highlighted.strip} => #{value}" end