Class: Sass::Script::Functions::EvaluationContext

Inherits:
Object
  • Object
show all
Includes:
Defined in:
/var/www/sass-pages/.sass/lib/sass/script/functions.rb

Overview

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

Instance Attribute Summary

Instance Method Summary

Methods included from

#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

- (EvaluationContext) initialize(options)

A new instance of EvaluationContext

Parameters:

  • ({Symbol => Object}) options — See #options


306
307
308
# File '/var/www/sass-pages/.sass/lib/sass/script/functions.rb', line 306

def initialize(options)
  @options = options
end

Instance Attribute Details

- ({Symbol => Object}) options (readonly)

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

Returns:

  • ({Symbol => Object})


303
304
305
# File '/var/www/sass-pages/.sass/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.

Examples:

  assert_type value, :String
  assert_type value, :Number

Parameters:

  • (Sass::Script::Literal) value — A SassScript value
  • (Symbol) type — The name of the type the value is expected to be
  • (String, nil) name (defaults to: nil) — The name of the argument.

Raises:

  • (ArgumentError)


323
324
325
326
327
328
# File '/var/www/sass-pages/.sass/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