Class: Sass::Script::Functions::EvaluationContext
- Inherits:
-
Object
- Object
- Sass::Script::Functions::EvaluationContext
- Includes:
- Sass::Script::Functions
- Defined in:
- lib/sass/script/functions.rb
Overview
The context in which methods in Sass::Script::Functions are evaluated. That means that all instance methods of EvaluationContext are available to use in functions.
Instance Attribute Summary collapse
-
#options ⇒ {Symbol => Object}
readonly
The options hash for the Engine that is processing the function call.
Instance Method Summary collapse
-
#assert_type(value, type, name = nil)
Asserts that the type of a given SassScript value is the expected type (designated by a symbol).
-
#initialize(options) ⇒ EvaluationContext
constructor
A new instance of EvaluationContext.
Methods included from Sass::Script::Functions
#abs, #adjust_color, #adjust_hue, #alpha, #append, #blue, #ceil, #change_color, #comparable, #complement, #darken, declare, #desaturate, #floor, #grayscale, #green, #hsl, #hsla, #hue, #if, #index, #invert, #join, #length, #lighten, #lightness, #mix, #nth, #opacify, #opacity, #percentage, #quote, #red, #rgb, #rgba, #round, #saturate, #saturation, #scale_color, signature, #transparentize, #type_of, #unit, #unitless, #unquote, #zip
Constructor Details
#initialize(options) ⇒ EvaluationContext
Returns a new instance of EvaluationContext.
306 307 308 |
# File 'lib/sass/script/functions.rb', line 306
def initialize(options)
@options = options
end
|
Instance Attribute Details
#options ⇒ {Symbol => Object} (readonly)
The options hash for the Engine that is processing the function call
303 304 305 |
# File 'lib/sass/script/functions.rb', line 303
def options
@options
end
|
Instance Method Details
#assert_type(value, type, name = nil)
Asserts that the type of a given SassScript value is the expected type (designated by a symbol).
Valid types are :Bool
, :Color
, :Number
, and :String
.
Note that :String
will match both double-quoted strings
and unquoted identifiers.
323 324 325 326 327 328 |
# File 'lib/sass/script/functions.rb', line 323
def assert_type(value, type, name = nil)
return if value.is_a?(Sass::Script.const_get(type))
err = "#{value.inspect} is not a #{type.to_s.downcase}"
err = "$#{name}: " + err if name
raise ArgumentError.new(err)
end
|