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

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from Sass::Script::Functions

#abs, #alpha, #blue, #ceil, #floor, #green, #hsl, #hsla, #opacify, #percentage, #red, #rgb, #rgba, #round, #transparentize

Constructor Details

#initialize(options) ⇒ EvaluationContext

Returns a new instance of EvaluationContext.

Parameters:



103
104
105
# File 'lib/sass/script/functions.rb', line 103

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsHash<Symbol, Object> (readonly)

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

Returns:



100
101
102
# File 'lib/sass/script/functions.rb', line 100

def options
  @options
end

Instance Method Details

#assert_type(value, type) ⇒ Object

Asserts that the type of a given SassScript value is the expected type (designated by a symbol). For example:

assert_type value, :String
assert_type value, :Number

Valid types are :Bool, :Color, :Number, and :String.

Parameters:

  • value (Sass::Script::Literal)

    A SassScript value

  • type (Symbol)

    The name of the type the value is expected to be

Raises:

  • (ArgumentError)


118
119
120
121
# File 'lib/sass/script/functions.rb', line 118

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