Class: Sass::CalculationValue::CalculationOperation
- Inherits:
-
Object
- Object
- Sass::CalculationValue::CalculationOperation
- 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
- #left ⇒ CalculationValue readonly
- #operator ⇒ ::String readonly
- #right ⇒ CalculationValue readonly
Instance Method Summary collapse
- #==(other) ⇒ ::Boolean
- #hash ⇒ Integer
-
#initialize(operator, left, right) ⇒ CalculationOperation
constructor
A new instance of CalculationOperation.
Constructor Details
#initialize(operator, left, right) ⇒ CalculationOperation
Returns a new instance of CalculationOperation.
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
#left ⇒ CalculationValue (readonly)
30 31 32 |
# File 'lib/sass/calculation_value/calculation_operation.rb', line 30 def left @left end |
#operator ⇒ ::String (readonly)
27 28 29 |
# File 'lib/sass/calculation_value/calculation_operation.rb', line 27 def operator @operator end |
#right ⇒ CalculationValue (readonly)
33 34 35 |
# File 'lib/sass/calculation_value/calculation_operation.rb', line 33 def right @right end |
Instance Method Details
#==(other) ⇒ ::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 |
#hash ⇒ Integer
44 45 46 |
# File 'lib/sass/calculation_value/calculation_operation.rb', line 44 def hash @hash ||= [operator, left, right].hash end |