class Sass::Script::UnaryOperation

Currently only ‘-`, `/`, and `not` are unary operators.
such as `-!b` or `not true`.
A SassScript parse node representing a unary operation,

def initialize(operand, operator)

Parameters:
  • operator (Symbol) -- The operator to perform
  • operand (Script::Node) -- The parse-tree node
def initialize(operand, operator)
  @operand = operand
  @operator = operator
end

def inspect

Returns:
  • (String) - A human-readable s-expression representation of the operation
def inspect
  "(#{@operator.inspect} #{@operand.inspect})"
end

def perform(environment)

Raises:
  • (Sass::SyntaxError) - if the operation is undefined for the operand

Returns:
  • (Literal) - The SassScript object that is the value of the operation

Parameters:
  • environment (Sass::Environment) -- The environment in which to evaluate the SassScript
def perform(environment)
  operator = "unary_#{@operator}"
  literal = @operand.perform(environment)
  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