Class: Sass::Script::Functions::EvaluationContext
- Inherits:
-
Object
- Object
- Sass::Script::Functions::EvaluationContext
- 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)
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.
Constructor Details
#initialize(options) ⇒ EvaluationContext
Returns a new instance of EvaluationContext.
182 183 184 185 186 187 188 |
# File 'lib/sass/script/functions.rb', line 182
def initialize(options)
@options = options
# We need to include this individually in each instance
# because of an icky Ruby restriction
class << self; include Sass::Script::Functions; end
end
|
Instance Attribute Details
#options ⇒ {Symbol => Object} (readonly)
The options hash for the Engine that is processing the function call
179 180 181 |
# File 'lib/sass/script/functions.rb', line 179
def options
@options
end
|
Instance Method Details
#assert_type(value, type)
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.
202 203 204 205 |
# File 'lib/sass/script/functions.rb', line 202
def assert_type(value, type)
return if value.is_a?(Sass::Script.const_get(type))
raise ArgumentError.new("#{value.inspect} is not a #{type.to_s.downcase}")
end
|