Class: Sass::Value::Calculation
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#assert_calculation_value
#[], #assert_boolean, #assert_calculation_value, #assert_color, #assert_function, #assert_map, #assert_number, #assert_string, #at, #bracketed?, #eql?, #sass_index_to_array_index, #separator, #to_a, #to_bool, #to_map, #to_nil
Constructor Details
#initialize(name, arguments) ⇒ Calculation
Returns a new instance of Calculation.
12
13
14
15
|
# File 'lib/sass/value/calculation.rb', line 12
def initialize(name, arguments)
@name = name.freeze
@arguments = arguments.freeze
end
|
Instance Attribute Details
21
22
23
|
# File 'lib/sass/value/calculation.rb', line 21
def arguments
@arguments
end
|
#name ⇒ ::String
18
19
20
|
# File 'lib/sass/value/calculation.rb', line 18
def name
@name
end
|
Class Method Details
28
29
30
31
|
# File 'lib/sass/value/calculation.rb', line 28
def calc(argument)
argument.assert_calculation_value
new('calc', [argument])
end
|
.clamp(min, value = nil, max = nil) ⇒ Calculation
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/sass/value/calculation.rb', line 51
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 or CalculationInterpolation.'
end
arguments = [min]
arguments.push(value) unless value.nil?
arguments.push(max) unless max.nil?
arguments.each(&:assert_calculation_value)
new('clamp', arguments)
end
|
42
43
44
45
|
# File 'lib/sass/value/calculation.rb', line 42
def max(arguments)
arguments.each(&:assert_calculation_value)
new('max', arguments)
end
|
35
36
37
38
|
# File 'lib/sass/value/calculation.rb', line 35
def min(arguments)
arguments.each(&:assert_calculation_value)
new('min', arguments)
end
|
Instance Method Details
#==(other) ⇒ ::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
73
74
75
|
# File 'lib/sass/value/calculation.rb', line 73
def assert_calculation(_name = nil)
self
end
|
#hash ⇒ Integer
85
86
87
|
# File 'lib/sass/value/calculation.rb', line 85
def hash
@hash ||= [name, *arguments].hash
end
|