class Sass::Script::Tree::UnaryOperation

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

def _perform(environment)

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

Returns:
  • (Sass::Script::Value) - 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}"
  value = @operand.perform(environment)
  value.send(operator)
rescue NoMethodError => e
  raise e unless e.name.to_s == operator.to_s
  raise Sass::SyntaxError.new("Undefined unary operation: \"#{@operator} #{value}\".")
end

def children

Other tags:
    See: Node#children -

Returns:
  • (Array) -
def children
  [@operand]
end

def deep_copy

Other tags:
    See: Node#deep_copy -
def deep_copy
  node = dup
  node.instance_variable_set('@operand', @operand.deep_copy)
  node
end

def initialize(operand, operator)

Parameters:
  • operator (Symbol) -- See \{#operator}
  • operand (Script::Node) -- See \{#operand}
def initialize(operand, operator)
  @operand = operand
  @operator = operator
  super()
end

def inspect

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

def to_sass(opts = {})

Other tags:
    See: Node#to_sass -
def to_sass(opts = {})
  operand = @operand.to_sass(opts)
  if @operand.is_a?(Operation) ||
      (@operator == :minus &&
       (operand =~ Sass::SCSS::RX::IDENT) == 0)
    operand = "(#{@operand.to_sass(opts)})"
  end
  op = Sass::Script::Lexer::OPERATORS_REVERSE[@operator]
  op + (op =~ /[a-z]/ ? " " : "") + operand
end