lib/code/object.rb in template-ruby-0.2.4 vs lib/code/object.rb in template-ruby-0.3.0
- old
+ new
@@ -11,10 +11,12 @@
compare(arguments)
elsif operator == "&&"
and_operator(arguments)
elsif operator == "||"
or_operator(arguments)
+ elsif operator == "to_string"
+ to_string(arguments)
else
raise ::Code::Error::Undefined.new(
"#{operator} not defined on #{inspect}",
)
end
@@ -123,8 +125,13 @@
def or_operator(arguments)
sig(arguments, ::Code::Object)
other = arguments.first.value
truthy? ? self : other
+ end
+
+ def to_string(arguments)
+ sig(arguments)
+ ::Code::Object::String.new(to_s)
end
end
end