Class: Sass::CalculationValue::CalculationOperation

Inherits:
Object
  • Object
show all
Includes:
Sass::CalculationValue
Defined in:
lib/sass/calculation_value/calculation_operation.rb

Overview

A binary operation that can appear in a SassCalculation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operator, left, right) ⇒ CalculationOperation

Returns a new instance of CalculationOperation.

Parameters:

Raises:



18
19
20
21
22
23
24
# File 'lib/sass/calculation_value/calculation_operation.rb', line 18

def initialize(operator, left, right)
  raise Sass::ScriptError, "Invalid operator: #{operator}" unless OPERATORS.include?(operator)

  @operator = operator.freeze
  @left = assert_calculation_value(left, 'left')
  @right = assert_calculation_value(right, 'right')
end

Instance Attribute Details

#leftCalculationValue (readonly)

Returns:



30
31
32
# File 'lib/sass/calculation_value/calculation_operation.rb', line 30

def left
  @left
end

#operator::String (readonly)

Returns:

  • (::String)


27
28
29
# File 'lib/sass/calculation_value/calculation_operation.rb', line 27

def operator
  @operator
end

#rightCalculationValue (readonly)

Returns:



33
34
35
# File 'lib/sass/calculation_value/calculation_operation.rb', line 33

def right
  @right
end

Instance Method Details

#==(other) ⇒ ::Boolean

Returns:

  • (::Boolean)


36
37
38
39
40
41
# File 'lib/sass/calculation_value/calculation_operation.rb', line 36

def ==(other)
  other.is_a?(Sass::CalculationValue::CalculationOperation) &&
    other.operator == operator &&
    other.left == left &&
    other.right == right
end

#hashInteger

Returns:

  • (Integer)


44
45
46
# File 'lib/sass/calculation_value/calculation_operation.rb', line 44

def hash
  @hash ||= [operator, left, right].hash
end