Class: Sass::Value::Calculation

Inherits:
Object
  • Object
show all
Includes:
CalculationValue, Sass::Value
Defined in:
lib/sass/value/calculation.rb

Overview

Sass’s calculation type.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Sass::Value

#[], #assert_boolean, #assert_color, #assert_function, #assert_map, #assert_mixin, #assert_number, #assert_string, #at, #bracketed?, #eql?, #sass_index_to_array_index, #separator, #to_a, #to_bool, #to_map, #to_nil

Instance Attribute Details

#argumentsArray<CalculationValue> (readonly)

Returns:



70
71
72
# File 'lib/sass/value/calculation.rb', line 70

def arguments
  @arguments
end

#name::String (readonly)

Returns:

  • (::String)


67
68
69
# File 'lib/sass/value/calculation.rb', line 67

def name
  @name
end

Class Method Details

.calc(argument) ⇒ Calculation

Parameters:

Returns:



17
18
19
# File 'lib/sass/value/calculation.rb', line 17

def calc(argument)
  new('calc', [argument])
end

.clamp(min, value = nil, max = nil) ⇒ Calculation

Parameters:

Returns:



37
38
39
40
41
42
43
44
# File 'lib/sass/value/calculation.rb', line 37

def clamp(min, value = nil, max = nil)
  if (value.nil? && !valid_clamp_arg?(min)) ||
     (max.nil? && [min, value].none? { |x| x && valid_clamp_arg?(x) })
    raise Sass::ScriptError, 'Argument must be an unquoted SassString.'
  end

  new('clamp', [min, value, max].compact)
end

.max(arguments) ⇒ Calculation

Parameters:

Returns:



29
30
31
# File 'lib/sass/value/calculation.rb', line 29

def max(arguments)
  new('max', arguments)
end

.min(arguments) ⇒ Calculation

Parameters:

Returns:



23
24
25
# File 'lib/sass/value/calculation.rb', line 23

def min(arguments)
  new('min', arguments)
end

Instance Method Details

#==(other) ⇒ ::Boolean

Returns:

  • (::Boolean)


78
79
80
81
82
# File 'lib/sass/value/calculation.rb', line 78

def ==(other)
  other.is_a?(Sass::Value::Calculation) &&
    other.name == name &&
    other.arguments == arguments
end

#assert_calculation(_name = nil) ⇒ Calculation

Returns:



73
74
75
# File 'lib/sass/value/calculation.rb', line 73

def assert_calculation(_name = nil)
  self
end

#hashInteger

Returns:

  • (Integer)


85
86
87
# File 'lib/sass/value/calculation.rb', line 85

def hash
  @hash ||= [name, *arguments].hash
end