Module | Sass::Script::Value::Helpers |
In: |
lib/sass/script/value/helpers.rb
|
Provides helper functions for creating sass values from within ruby methods. @since `3.3.0` @comment
rubocop:disable ModuleLength
VALID_UNIT | = | /#{Sass::SCSS::RX::NMSTART}#{Sass::SCSS::RX::NMCHAR}|%*/ | @private |
Construct a Sass Boolean.
@param value [Object] A ruby object that will be tested for truthiness. @return [Sass::Script::Value::Bool] whether the ruby value is truthy.
Returns true when the literal is a string containing a calc()
@param literal [Sass::Script::Value::Base] The value to check @return boolean
Construct a Sass Color from hsl values.
@param hue [::Number] The hue of the color in degrees.
A non-negative number, usually less than 360.
@param saturation [::Number] The saturation of the color.
Must be between 0 and 100 inclusive.
@param lightness [::Number] The lightness of the color.
Must be between 0 and 100 inclusive.
@param alpha [::Number] The alpha channel. A number between 0 and 1.
@return [Sass::Script::Value::Color] the color object
@overload list(*elements, separator)
Create a space-separated list from the arguments given. @param elements [Array<Sass::Script::Value::Base>] Each argument will be a list element. @param separator [Symbol] Either :space or :comma. @return [Sass::Script::Value::List] The space separated list.
@overload list(array, separator)
Create a space-separated list from the array given. @param array [Array<Sass::Script::Value::Base>] A ruby array of Sass values to make into a list. @return [Sass::Script::Value::List] The space separated list.
@param hash [Hash<Sass::Script::Value::Base,
Sass::Script::Value::Base>] A Ruby map to convert to a Sass map.
@return [Sass::Script::Value::Map] The map.
Construct a Sass Number from a ruby number.
@param number [::Number] A numeric value. @param unit_string [::String] A unit string of the form
`numeral_unit1 * numeral_unit2 ... / denominator_unit1 * denominator_unit2 ...` this is the same format that is returned by {Sass::Script::Value::Number#unit_str the `unit_str` method}
@see Sass::Script::Value::Number#unit_str
@return [Sass::Script::Value::Number] The sass number representing the given ruby number.
Parses a user-provided complex selector.
A complex selector can contain combinators but cannot contain commas.
@param value [Sass::Script::Value::String, Sass::Script::Value::List]
The selector to parse. This can be either a string or a list of strings.
@param name [Symbol, nil]
If provided, the name of the selector argument. This is used for error reporting.
@param allow_parent_ref [Boolean]
Whether the parsed selector should allow parent references.
@return [Sass::Selector::Sequence] The parsed selector. @throw [ArgumentError] if the parse failed for any reason.
Parses a user-provided compound selector.
A compound selector cannot contain combinators or commas.
@param value [Sass::Script::Value::String] The selector to parse. @param name [Symbol, nil]
If provided, the name of the selector argument. This is used for error reporting.
@param allow_parent_ref [Boolean]
Whether the parsed selector should allow parent references.
@return [Sass::Selector::SimpleSequence] The parsed selector. @throw [ArgumentError] if the parse failed for any reason.
Parses a user-provided selector.
@param value [Sass::Script::Value::String, Sass::Script::Value::List]
The selector to parse. This can be either a string, a list of strings, or a list of lists of strings as returned by `&`.
@param name [Symbol, nil]
If provided, the name of the selector argument. This is used for error reporting.
@param allow_parent_ref [Boolean]
Whether the parsed selector should allow parent references.
@return [Sass::Selector::CommaSequence] The parsed selector. @throw [ArgumentError] if the parse failed for any reason.
Create a quoted string.
@param str [::String] A ruby string. @return [Sass::Script::Value::String] A quoted string.
Construct a Sass Color from rgb values.
@param red [::Number] The red component. Must be between 0 and 255 inclusive. @param green [::Number] The green component. Must be between 0 and 255 inclusive. @param blue [::Number] The blue component. Must be between 0 and 255 inclusive. @param alpha [::Number] The alpha channel. A number between 0 and 1.
@return [Sass::Script::Value::Color] the color object
Create an unquoted string.
@param str [::String] A ruby string. @return [Sass::Script::Value::String] An unquoted string.