lib/gobstones/lang/expressions/var_name.rb in gobstones-0.0.2 vs lib/gobstones/lang/expressions/var_name.rb in gobstones-0.0.3
- old
+ new
@@ -1,37 +1,33 @@
-require 'gobstones/modules/equal_by_class'
+require 'gobstones/lang/expressions/expression'
module Gobstones
-
module Lang
-
- class VarName
-
- include Gobstones::EqualByClass
-
+ class VarName < Expression
attr_reader :name
def initialize(name)
@name = name
end
- def ==(var)
- super(var) && self.name == var.name
+ def equality_attributes
+ %i[name]
end
def hash
- @name.hash
+ name.hash
end
def evaluate(context)
- context.get self
+ context.get(self)
end
def named?(a_name)
name == a_name
end
+ def to_s
+ "variable named '#{name}'"
+ end
end
-
end
-
end