2008-10-12 22:03:06 -04:00
|
|
|
module Sass::Script
|
2008-06-15 04:15:59 -04:00
|
|
|
class UnaryOperation # :nodoc:
|
|
|
|
def initialize(operand, operator)
|
|
|
|
@operand = operand
|
|
|
|
@operator = operator
|
|
|
|
end
|
|
|
|
|
|
|
|
def inspect
|
|
|
|
"(#{@operator.inspect} #{@operand.inspect})"
|
|
|
|
end
|
|
|
|
|
2008-10-12 23:26:56 -04:00
|
|
|
def perform(environment)
|
2008-06-15 04:15:59 -04:00
|
|
|
operator = "unary_#{@operator}"
|
2008-10-12 23:26:56 -04:00
|
|
|
literal = @operand.perform(environment)
|
2008-06-15 04:15:59 -04:00
|
|
|
literal.send(operator)
|
|
|
|
rescue NoMethodError => e
|
|
|
|
raise e unless e.name.to_s == operator.to_s
|
|
|
|
raise Sass::SyntaxError.new("Undefined unary operation: \"#{@operator} #{literal}\".")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|