Class Sass::Script::Funcall
In: lib/sass/script/funcall.rb
Parent: Node
Haml::Util Engine Color SyntaxError UnitConversionError StandardError Node Operation Literal UnaryOperation Funcall Variable Number String Bool EvaluationContext Node\n[lib/sass/css.rb\nlib/sass/tree/node.rb] DebugNode IfNode CommentNode ForNode MixinNode VariableNode ImportNode WhileNode MixinDefNode Repl CSS Environment Lexer Parser PropNode\n[lib/sass/css.rb\nlib/sass/tree/prop_node.rb] DirectiveNode\n[lib/sass/css.rb\nlib/sass/tree/directive_node.rb] RuleNode\n[lib/sass/css.rb\nlib/sass/tree/rule_node.rb] Rack lib/sass/repl.rb lib/sass/css.rb lib/sass/environment.rb lib/sass/error.rb lib/sass/engine.rb lib/sass/script/lexer.rb lib/sass/script/color.rb lib/sass/script/string.rb lib/sass/script/unary_operation.rb lib/sass/script/variable.rb lib/sass/script/funcall.rb lib/sass/script/operation.rb lib/sass/script/bool.rb lib/sass/script/parser.rb lib/sass/script/literal.rb lib/sass/script/node.rb lib/sass/script/number.rb lib/sass/script/functions.rb Functions Script Files lib/sass/tree/while_node.rb lib/sass/tree/if_node.rb lib/sass/tree/mixin_def_node.rb lib/sass/tree/debug_node.rb lib/sass/tree/for_node.rb lib/sass/tree/import_node.rb lib/sass/tree/prop_node.rb lib/sass/tree/node.rb lib/sass/tree/comment_node.rb lib/sass/tree/mixin_node.rb lib/sass/tree/directive_node.rb lib/sass/tree/rule_node.rb lib/sass/tree/variable_node.rb Tree lib/sass/plugin/rack.rb Plugin Sass dot/m_54_0.png

A SassScript parse node representing a function call.

A function call either calls one of the functions in {Script::Functions}, or if no function with the given name exists it returns a string representation of the function call.

Methods

inspect   new   perform  

Attributes

args  [R]  The arguments to the function.

@return [Array<Script::Node>]

name  [R]  The name of the function.

@return [String]

Public Class methods

@param name [String] See \{name} @param name [Array<Script::Node>] See \{args}

[Source]

    # File lib/sass/script/funcall.rb, line 22
22:       def initialize(name, args)
23:         @name = name
24:         @args = args
25:       end

Public Instance methods

@return [String] A string representation of the function call

[Source]

    # File lib/sass/script/funcall.rb, line 28
28:       def inspect
29:         "#{name}(#{args.map {|a| a.inspect}.join(', ')})"
30:       end

Evaluates the function call.

@param environment [Sass::Environment] The environment in which to evaluate the SassScript @return [Literal] The SassScript object that is the value of the function call @raise [Sass::SyntaxError] if the function call raises an ArgumentError

[Source]

    # File lib/sass/script/funcall.rb, line 37
37:       def perform(environment)
38:         args = self.args.map {|a| a.perform(environment)}
39:         unless Haml::Util.has?(:public_instance_method, Functions, name) && name !~ /^__/
40:           return Script::String.new("#{name}(#{args.map {|a| a.perform(environment)}.join(', ')})")
41:         end
42: 
43:         return Functions::EvaluationContext.new(environment.options).send(name, *args)
44:       rescue ArgumentError => e
45:         raise e unless e.backtrace.any? {|t| t =~ /:in `(block in )?(#{name}|perform)'$/}
46:         raise Sass::SyntaxError.new("#{e.message} for `#{name}'")
47:       end

[Validate]