Class: Sass::Script::Funcall
Overview
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.
Instance Attribute Summary
- - (Array<Script::Node>) args readonly The arguments to the function.
- - (String) name readonly The name of the function.
Instance Method Summary
- - (Literal) _perform(environment) protected Evaluates the function call.
- - (Array<Node>) children Returns the arguments to the function.
-
- context(context)
Don’t set the context for child nodes if this is
url(), sinceurl()allows quoted strings. - - (Funcall) initialize(name, args) constructor A new instance of Funcall.
- - (String) inspect A string representation of the function call.
- - to_sass(opts = {})
Methods inherited from Node
Constructor Details
- (Funcall) initialize(name, args)
A new instance of Funcall
31 32 33 34 35 |
# File '/var/www/haml-pages/.haml/lib/sass/script/funcall.rb', line 31
def initialize(name, args)
@name = name
@args = args
super()
end
|
Instance Attribute Details
- (Array<Script::Node>) args (readonly)
The arguments to the function.
18 19 20 |
# File '/var/www/haml-pages/.haml/lib/sass/script/funcall.rb', line 18
def args
@args
end
|
- (String) name (readonly)
The name of the function.
13 14 15 |
# File '/var/www/haml-pages/.haml/lib/sass/script/funcall.rb', line 13
def name
@name
end
|
Instance Method Details
- (Literal) _perform(environment) (protected)
Evaluates the function call.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File '/var/www/haml-pages/.haml/lib/sass/script/funcall.rb', line 62
def _perform(environment)
args = self.args.map {|a| a.perform(environment)}
ruby_name = name.gsub('-', '_')
unless Haml::Util.has?(:public_instance_method, Functions, ruby_name) && ruby_name !~ /^__/
return Script::String.new("#{name}(#{args.map {|a| a.perform(environment)}.join(', ')})")
end
result = Functions::EvaluationContext.new(environment.options).send(ruby_name, *args)
result.options = environment.options
return result
rescue ArgumentError => e
raise e unless e.backtrace.any? {|t| t =~ /:in `(block in )?(#{name}|perform)'$/}
raise Sass::SyntaxError.new("#{e.message} for `#{name}'")
end
|
- (Array<Node>) children
Returns the arguments to the function.
51 52 53 |
# File '/var/www/haml-pages/.haml/lib/sass/script/funcall.rb', line 51
def children
@args
end
|
- context=(context)
Don’t set the context for child nodes if this is url(), since url() allows quoted strings.
25 26 27 |
# File '/var/www/haml-pages/.haml/lib/sass/script/funcall.rb', line 25
def context=(context)
super unless @name == "url"
end
|
- (String) inspect
A string representation of the function call
38 39 40 |
# File '/var/www/haml-pages/.haml/lib/sass/script/funcall.rb', line 38
def inspect
"#{name}(#{args.map {|a| a.inspect}.join(', ')})"
end
|
- to_sass(opts = {})
43 44 45 |
# File '/var/www/haml-pages/.haml/lib/sass/script/funcall.rb', line 43
def to_sass(opts = {})
"#{dasherize(name, opts)}(#{args.map {|a| a.to_sass(opts)}.join(', ')})"
end
|