Frage

Can someone tell me what this method does or where I can find documentation on it?

declare :percentage, [:value]

It's difficult to research this one because I keep getting documentation about declaring variables, methods, etc.

Thanks!

War es hilfreich?

Lösung

.declare is not part of Ruby's standard library. It seems to exist in the Sass gem.

It is declared in the Sass::Script::Functions module: here

Here is the relevant documentation:

declare(method_name, args, options = {})


Declare a Sass signature for a Ruby-defined function. This includes the names of the arguments, whether the function takes a variable number of arguments, and whether the function takes an arbitrary set of keyword arguments.

It’s not necessary to declare a signature for a function. However, without a signature it won’t support keyword arguments.

A single function can have multiple signatures declared as long as each one takes a different number of arguments. It’s also possible to declare multiple signatures that all take the same number of arguments, but none of them but the first will be used unless the user uses keyword arguments.

Examples:

 declare :rgba, [:hex, :alpha]
 declare :rgba, [:red, :green, :blue, :alpha]
 declare :accepts_anything, [], :var_args => true, :var_kwargs => true
 declare :some_func, [:foo, :bar, :baz], :var_kwargs => true

Parameters:

method_name (Symbol) —

The name of the method whose signature is being declared.
args (Array<Symbol>) —

The names of the arguments for the function signature.
options (Hash) (defaults to: {}) —

a customizable set of options

Options Hash (options):

:var_args (Boolean) — default: false —

Whether the function accepts a variable number of (unnamed) arguments in addition to the named arguments.
:var_kwargs (Boolean) — default: false —

Whether the function accepts other keyword arguments in addition to those in :args. If this is true, the Ruby function will be passed a hash from strings to Literals as the last argument. In addition, if this is true and :var_args is not, Sass will ensure that the last argument passed is a hash.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top