Method: Sass::Script::Tree::Operation#_perform
- Defined in:
- lib/sass/script/tree/operation.rb
#_perform(environment) ⇒ Sass::Script::Value (protected)
Evaluates the operation.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/sass/script/tree/operation.rb', line 66
def _perform(environment)
value1 = @operand1.perform(environment)
# Special-case :and and :or to support short-circuiting.
if @operator == :and
return value1.to_bool ? @operand2.perform(environment) : value1
elsif @operator == :or
return value1.to_bool ? value1 : @operand2.perform(environment)
end
value2 = @operand2.perform(environment)
if (value1.is_a?(Sass::Script::Value::Null) || value2.is_a?(Sass::Script::Value::Null)) &&
@operator != :eq && @operator != :neq
raise Sass::SyntaxError.new(
"Invalid null operation: \"#{value1.inspect} #{@operator} #{value2.inspect}\".")
end
begin
result = opts(value1.send(@operator, value2))
rescue NoMethodError => e
raise e unless e.name.to_s == @operator.to_s
raise Sass::SyntaxError.new("Undefined operation: \"#{value1} #{@operator} #{value2}\".")
end
warn_for_color_arithmetic(value1, value2)
warn_for_unitless_equals(value1, value2, result)
result
end
|