SassString
A Sass string value.
Strings may be quoted.
SassString indexes
Sass models strings as a sequence of unicode scalars, not Swift’s primary view as a sequence of extended grapheme clusters. So any string index you receive through Sass applies to the unicode scalar view of the string.
Further, Sass models 1 as the index of the first scalar in the string, and count
as the index of the last.
This class offers a scalarIndexFrom(sassIndex:)
method to wrap up both parts of this
conversion, but offers only sympathy to users having to deal with the results.
SassString
conforms to Sequence
Sequence
via SassValue
. This sequence is a singleton sequence
containing the string value, not a sequence of scalars.
Topics
Initializers
init(String, isQuoted: Bool)
init(String, isQuoted: Bool)
Properties
var string: String
var string: String
var isQuoted: Bool
var isQuoted: Bool
var sassLength: Int
var sassLength: Int
The length of the string according to Sass.
The number of unicode scalars in the string.
Declaration
public var sassLength: Int { get }
Methods
func scalarIndexFrom(sassIndex: SassValue) -> String.UnicodeScalarIndex
func scalarIndexFrom(sassIndex: SassValue) -> String.UnicodeScalarIndex
Interpret a Sass string index.
Declaration
public func scalarIndexFrom(sassIndex: SassValue) throws
-> String.UnicodeScalarIndex
Parameters
index |
A Sass value intended to be used as a string index. This must be an
integer between 1 and |
Throws
SassFunctionError
if sassIndex
is not an integer or out of range.
Misc
static func ==(lhs: SassString, rhs: SassString) -> Bool
static func ==(lhs: SassString, rhs: SassString) -> Bool
Two SassString
s are equal if they have the same text, whether or not either is quoted.
Declaration
public static func == (lhs: SassString, rhs: SassString) -> Bool
func accept<V, R>(visitor: V) -> R
func accept<V, R>(visitor: V) -> R
Take part in the SassValueVisitor
protocol.
Declaration
public override func accept<V, R>(visitor: V) throws -> R
where V: SassValueVisitor, R == V.ReturnType
var description: String
var description: String
func hash(into: inout Hasher)
func hash(into: inout Hasher)