Class Sass::Script::UnaryOperation
In: lib/sass/script/unary_operation.rb
Parent: Node

A SassScript parse node representing a unary operation, such as `-!b` or `not true`.

Currently only `-`, `/`, and `not` are unary operators.

Methods

inspect   new   perform  

Public Class methods

@param operand [Script::Node] The parse-tree node

  for the object of the operator

@param operator [Symbol] The operator to perform

[Source]

    # File lib/sass/script/unary_operation.rb, line 10
10:     def initialize(operand, operator)
11:       @operand = operand
12:       @operator = operator
13:     end

Public Instance methods

@return [String] A human-readable s-expression representation of the operation

[Source]

    # File lib/sass/script/unary_operation.rb, line 16
16:     def inspect
17:       "(#{@operator.inspect} #{@operand.inspect})"
18:     end

Evaluates the operation.

@param environment [Sass::Environment] The environment in which to evaluate the SassScript @return [Literal] The SassScript object that is the value of the operation @raise [Sass::SyntaxError] if the operation is undefined for the operand

[Source]

    # File lib/sass/script/unary_operation.rb, line 25
25:     def perform(environment)
26:       operator = "unary_#{@operator}"
27:       literal = @operand.perform(environment)
28:       literal.send(operator)
29:     rescue NoMethodError => e
30:       raise e unless e.name.to_s == operator.to_s
31:       raise Sass::SyntaxError.new("Undefined unary operation: \"#{@operator} #{literal}\".")
32:     end

[Validate]