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

Inherits:
Object
  • Object
show all
Extends:
Defined in:
/var/www/haml-pages/.haml/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

Constructor Details

- (EvaluationContext) initialize(options)

A new instance of EvaluationContext

Parameters:



179
180
181
182
183
184
185
# File '/var/www/haml-pages/.haml/lib/sass/script/functions.rb', line 179

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

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

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

Returns:



176
177
178
# File '/var/www/haml-pages/.haml/lib/sass/script/functions.rb', line 176

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). For example:

assert_type value, :String
assert_type value, :Number

Valid types are :Bool, :Color, :Number, and :String. Note that :String will match both double-quoted strings and unquoted identifiers.

Parameters:

  • (Sass::Script::Literal) value — A SassScript value
  • (Symbol) type — The name of the type the value is expected to be

Raises:

  • (ArgumentError)


200
201
202
203
# File '/var/www/haml-pages/.haml/lib/sass/script/functions.rb', line 200

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