class Sass::Script::Functions::EvaluationContext

The context in which methods in {Script::Functions} are evaluated. That means that all instance methods of {EvaluationContext} are available to use in functions.

Attributes

options[R]

The options hash for the {Sass::Engine} that is processing the function call

@return [{Symbol => Object}]

Public Class Methods

new(options) click to toggle source

@param options [{Symbol => Object}] See {#options}

# File lib/sass/script/functions.rb, line 309
def initialize(options)
  @options = options
end

Public Instance Methods

assert_type(value, type, name = nil) click to toggle source

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.

@example

assert_type value, :String
assert_type value, :Number

@param value [Sass::Script::Literal] A SassScript value @param type [Symbol] The name of the type the value is expected to be @param name [String, nil] The name of the argument.

# File lib/sass/script/functions.rb, line 326
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