Module: Sass::Value
- Included in:
- Boolean, Color, Function, List, Map, Null, Number, String
- Defined in:
- lib/sass/value.rb,
lib/sass/value/map.rb,
lib/sass/value/list.rb,
lib/sass/value/null.rb,
lib/sass/value/color.rb,
lib/sass/value/number.rb,
lib/sass/value/string.rb,
lib/sass/value/boolean.rb,
lib/sass/value/function.rb,
lib/sass/value/fuzzy_math.rb,
lib/sass/value/number/unit.rb,
lib/sass/value/argument_list.rb
Overview
The abstract base class of Sass’s value types.
Defined Under Namespace
Classes: ArgumentList, Boolean, Color, Function, List, Map, Null, Number, String
Instance Method Summary
collapse
Instance Method Details
#[](index) ⇒ Value
27
28
29
|
# File 'lib/sass/value.rb', line 27
def [](index)
at(index)
end
|
#assert_boolean(name = nil) ⇒ Boolean
59
60
61
|
# File 'lib/sass/value.rb', line 59
def assert_boolean(name = nil)
raise Sass::ScriptError.new("#{self} is not a boolean", name)
end
|
#assert_calculation(name = nil) ⇒ Object
64
65
66
|
# File 'lib/sass/value.rb', line 64
def assert_calculation(name = nil)
raise Sass::ScriptError.new("#{self} is not a calculation", name)
end
|
#assert_color(name = nil) ⇒ Color
70
71
72
|
# File 'lib/sass/value.rb', line 70
def assert_color(name = nil)
raise Sass::ScriptError.new("#{self} is not a color", name)
end
|
#assert_function(name = nil) ⇒ Function
76
77
78
|
# File 'lib/sass/value.rb', line 76
def assert_function(name = nil)
raise Sass::ScriptError.new("#{self} is not a function", name)
end
|
#assert_map(name = nil) ⇒ Map
82
83
84
|
# File 'lib/sass/value.rb', line 82
def assert_map(name = nil)
raise Sass::ScriptError.new("#{self} is not a map", name)
end
|
#assert_number(name = nil) ⇒ Number
88
89
90
|
# File 'lib/sass/value.rb', line 88
def assert_number(name = nil)
raise Sass::ScriptError.new("#{self} is not a number", name)
end
|
#assert_string(name = nil) ⇒ String
94
95
96
|
# File 'lib/sass/value.rb', line 94
def assert_string(name = nil)
raise Sass::ScriptError.new("#{self} is not a string", name)
end
|
#at(index) ⇒ Value
33
34
35
|
# File 'lib/sass/value.rb', line 33
def at(index)
index < 1 && index >= -1 ? self : nil
end
|
#bracketed? ⇒ ::Boolean
16
17
18
|
# File 'lib/sass/value.rb', line 16
def bracketed?
false
end
|
#eql?(other) ⇒ ::Boolean
21
22
23
|
# File 'lib/sass/value.rb', line 21
def eql?(other)
self == other
end
|
#sass_index_to_array_index(sass_index, name = nil) ⇒ Integer
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/sass/value.rb', line 100
def sass_index_to_array_index(sass_index, name = nil)
index = sass_index.assert_number(name).assert_integer(name)
raise Sass::ScriptError.new('List index may not be 0', name) if index.zero?
if index.abs > to_a_length
raise Sass::ScriptError.new("Invalid index #{sass_index} for a list with #{to_a_length} elements", name)
end
index.negative? ? to_a_length + index : index - 1
end
|
#separator ⇒ ::String?
11
12
13
|
# File 'lib/sass/value.rb', line 11
def separator
nil
end
|
#to_a ⇒ Array<Value>
38
39
40
|
# File 'lib/sass/value.rb', line 38
def to_a
[self]
end
|
#to_bool ⇒ ::Boolean
43
44
45
|
# File 'lib/sass/value.rb', line 43
def to_bool
true
end
|
#to_map ⇒ Map?
48
49
50
|
# File 'lib/sass/value.rb', line 48
def to_map
nil
end
|
#to_nil ⇒ Value?
53
54
55
|
# File 'lib/sass/value.rb', line 53
def to_nil
self
end
|