Class: Sass::Value::String
- Inherits:
-
Object
- Object
- Sass::Value::String
show all
- Includes:
- Sass::Value
- Defined in:
- lib/sass/value/string.rb
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
#[], #assert_boolean, #assert_calculation, #assert_color, #assert_function, #assert_map, #assert_number, #at, #bracketed?, #eql?, #sass_index_to_array_index, #separator, #to_a, #to_bool, #to_map, #to_nil
Constructor Details
#initialize(text = '', quoted: true) ⇒ String
Returns a new instance of String.
13
14
15
16
|
# File 'lib/sass/value/string.rb', line 13
def initialize(text = '', quoted: true)
@text = text.freeze
@quoted = quoted
end
|
Instance Attribute Details
#text ⇒ ::String
19
20
21
|
# File 'lib/sass/value/string.rb', line 19
def text
@text
end
|
Instance Method Details
#==(other) ⇒ ::Boolean
27
28
29
|
# File 'lib/sass/value/string.rb', line 27
def ==(other)
other.is_a?(Sass::Value::String) && other.text == text
end
|
#assert_string(_name = nil) ⇒ String
37
38
39
|
# File 'lib/sass/value/string.rb', line 37
def assert_string(_name = nil)
self
end
|
#hash ⇒ Integer
32
33
34
|
# File 'lib/sass/value/string.rb', line 32
def hash
@hash ||= text.hash
end
|
#quoted? ⇒ ::Boolean
22
23
24
|
# File 'lib/sass/value/string.rb', line 22
def quoted?
@quoted
end
|
#sass_index_to_string_index(sass_index, name = nil) ⇒ Integer
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/sass/value/string.rb', line 43
def sass_index_to_string_index(sass_index, name = nil)
index = sass_index.assert_number(name).assert_integer(name)
raise Sass::ScriptError.new('String index may not be 0', name) if index.zero?
if index.abs > text.length
raise Sass::ScriptError.new("Invalid index #{sass_index} for a string with #{text.length} characters", name)
end
index.negative? ? text.length + index : index - 1
end
|