Class Sass::Script::Functions::EvaluationContext
In: lib/sass/script/functions.rb
Parent: Object

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

Methods

Included Modules

Functions Value::Helpers

Constants

TYPE_NAMES = {:ArgList => 'variable argument list'}   The human-readable names for [Sass::Script::Value::Base]. The default is just the downcased name of the type.

Attributes

environment  [R]  The environment for this function. This environment‘s {Environment#parent} is the global environment, and its {Environment#caller} is a read-only view of the local environment of the caller of this function.

@return [Environment]

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

@return [{Symbol => Object}]

Public Class methods

@param environment [Environment] See \{environment}

Public Instance methods

Asserts that the value is an integer.

@example

  assert_integer 2px
  assert_integer 2.5px
    => SyntaxError: "Expected 2.5px to be an integer"
  assert_integer 2.5px, "width"
    => SyntaxError: "Expected width to be an integer but got 2.5px"

@param number [Sass::Script::Value::Base] The value to be validated. @param name [::String] The name of the parameter being validated. @raise [ArgumentError] if number is not an integer or is not a number.

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::Value::Base] A SassScript value @param type [Symbol] The name of the type the value is expected to be @param name [String, Symbol, nil] The name of the argument. @raise [ArgumentError] if value is not of the correct type.

Asserts that the unit of the number is as expected.

@example

  assert_unit number, "px"
  assert_unit number, nil

@param number [Sass::Script::Value::Number] The number to be validated. @param unit [::String]

  The unit that the number must have.
  If nil, the number must be unitless.

@param name [::String] The name of the parameter being validated. @raise [ArgumentError] if number is not of the correct unit or is not a number.

Performs a node that has been delayed for execution.

@private @param node [Sass::Script::Tree::Node,

  Sass::Script::Value::Base] When this is a tree node, it's
  performed in the caller's environment. When it's a value
  (which can happen when the value had to be performed already
  -- like for a splat), it's returned as-is.

@param env [Sass::Environment] The environment within which to perform the node.

  Defaults to the (read-only) environment of the caller.

[Validate]