code
stringlengths 26
124k
| docstring
stringlengths 23
125k
| func_name
stringlengths 1
98
| language
stringclasses 1
value | repo
stringlengths 5
53
| path
stringlengths 7
151
| url
stringlengths 50
211
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
def map_values(map)
assert_type map, :Map, :map
list(map.to_h.values, :comma)
end
|
Returns a list of all values in a map. This list may include duplicate
values, if multiple keys have the same value.
@example
map-values(("foo": 1, "bar": 2)) => 1, 2
map-values(("foo": 1, "bar": 2, "baz": 1)) => 1, 2, 1
@overload map_values($map)
@param $map [Map]
@return [List] the list of values, comma-separated
@raise [ArgumentError] if `$map` is not a map
|
map_values
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def map_has_key(map, key)
assert_type map, :Map, :map
bool(map.to_h.has_key?(key))
end
|
Returns whether a map has a value associated with a given key.
@example
map-has-key(("foo": 1, "bar": 2), "foo") => true
map-has-key(("foo": 1, "bar": 2), "baz") => false
@overload map_has_key($map, $key)
@param $map [Sass::Script::Value::Map]
@param $key [Sass::Script::Value::Base]
@return [Sass::Script::Value::Bool]
@raise [ArgumentError] if `$map` is not a map
|
map_has_key
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def keywords(args)
assert_type args, :ArgList, :args
map(Sass::Util.map_keys(args.keywords.as_stored) {|k| Sass::Script::Value::String.new(k)})
end
|
Returns the map of named arguments passed to a function or mixin that
takes a variable argument list. The argument names are strings, and they
do not contain the leading `$`.
@example
@mixin foo($args...) {
@debug keywords($args); //=> (arg1: val, arg2: val)
}
@include foo($arg1: val, $arg2: val);
@overload keywords($args)
@param $args [Sass::Script::Value::ArgList]
@return [Sass::Script::Value::Map]
@raise [ArgumentError] if `$args` isn't a variable argument list
|
keywords
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def if(condition, if_true, if_false)
if condition.to_bool
perform(if_true)
else
perform(if_false)
end
end
|
Returns one of two values, depending on whether or not `$condition` is
true. Just like in `@if`, all values other than `false` and `null` are
considered to be true.
@example
if(true, 1px, 2px) => 1px
if(false, 1px, 2px) => 2px
@overload if($condition, $if-true, $if-false)
@param $condition [Sass::Script::Value::Base] Whether the `$if-true` or
`$if-false` will be returned
@param $if-true [Sass::Script::Tree::Node]
@param $if-false [Sass::Script::Tree::Node]
@return [Sass::Script::Value::Base] `$if-true` or `$if-false`
|
if
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def unique_id
generator = Sass::Script::Functions.random_number_generator
Thread.current[:sass_last_unique_id] ||= generator.rand(36**8)
# avoid the temptation of trying to guess the next unique value.
value = (Thread.current[:sass_last_unique_id] += (generator.rand(10) + 1))
# the u makes this a legal identifier if it would otherwise start with a number.
identifier("u" + value.to_s(36).rjust(8, '0'))
end
|
Returns a unique CSS identifier. The identifier is returned as an unquoted
string. The identifier returned is only guaranteed to be unique within the
scope of a single Sass run.
@overload unique_id()
@return [Sass::Script::Value::String]
|
unique_id
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def call(name, *args)
unless name.is_a?(Sass::Script::Value::String) ||
name.is_a?(Sass::Script::Value::Function)
assert_type name, :Function, :function
end
if name.is_a?(Sass::Script::Value::String)
name = if function_exists(name).to_bool
get_function(name)
else
get_function(name, "css" => bool(true))
end
Sass::Util.sass_warn(<<WARNING)
DEPRECATION WARNING: Passing a string to call() is deprecated and will be illegal
in Sass 4.0. Use call(#{name.to_sass}) instead.
WARNING
end
kwargs = args.last.is_a?(Hash) ? args.pop : {}
funcall = Sass::Script::Tree::Funcall.new(
name.value,
args.map {|a| Sass::Script::Tree::Literal.new(a)},
Sass::Util.map_vals(kwargs) {|v| Sass::Script::Tree::Literal.new(v)},
nil,
nil)
funcall.line = environment.stack.frames.last.line
funcall.filename = environment.stack.frames.last.filename
funcall.options = options
perform(funcall)
end
|
Dynamically calls a function. This can call user-defined
functions, built-in functions, or plain CSS functions. It will
pass along all arguments, including keyword arguments, to the
called function.
@example
call(rgb, 10, 100, 255) => #0a64ff
call(scale-color, #0a64ff, $lightness: -10%) => #0058ef
$fn: nth;
call($fn, (a b c), 2) => b
@overload call($function, $args...)
@param $function [Sass::Script::Value::Function] The function to call.
|
call
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def counter(*args)
identifier("counter(#{args.map {|a| a.to_s(options)}.join(',')})")
end
|
This function only exists as a workaround for IE7's [`content:
counter` bug](http://jes.st/2013/ie7s-css-breaking-content-counter-bug/).
It works identically to any other plain-CSS function, except it
avoids adding spaces between the argument commas.
@example
counter(item, ".") => counter(item,".")
@overload counter($args...)
@return [Sass::Script::Value::String]
|
counter
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def counters(*args)
identifier("counters(#{args.map {|a| a.to_s(options)}.join(',')})")
end
|
This function only exists as a workaround for IE7's [`content:
counter` bug](http://jes.st/2013/ie7s-css-breaking-content-counter-bug/).
It works identically to any other plain-CSS function, except it
avoids adding spaces between the argument commas.
@example
counters(item, ".") => counters(item,".")
@overload counters($args...)
@return [Sass::Script::Value::String]
|
counters
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def variable_exists(name)
assert_type name, :String, :name
bool(environment.caller.var(name.value))
end
|
Check whether a variable with the given name exists in the current
scope or in the global scope.
@example
$a-false-value: false;
variable-exists(a-false-value) => true
variable-exists(a-null-value) => true
variable-exists(nonexistent) => false
@overload variable_exists($name)
@param $name [Sass::Script::Value::String] The name of the variable to
check. The name should not include the `$`.
@return [Sass::Script::Value::Bool] Whether the variable is defined in
the current scope.
|
variable_exists
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def global_variable_exists(name)
assert_type name, :String, :name
bool(environment.global_env.var(name.value))
end
|
Check whether a variable with the given name exists in the global
scope (at the top level of the file).
@example
$a-false-value: false;
global-variable-exists(a-false-value) => true
global-variable-exists(a-null-value) => true
.foo {
$some-var: false;
@if global-variable-exists(some-var) { /* false, doesn't run */ }
}
@overload global_variable_exists($name)
@param $name [Sass::Script::Value::String] The name of the variable to
check. The name should not include the `$`.
@return [Sass::Script::Value::Bool] Whether the variable is defined in
the global scope.
|
global_variable_exists
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def function_exists(name)
assert_type name, :String, :name
exists = Sass::Script::Functions.callable?(name.value.tr("-", "_"))
exists ||= environment.caller.function(name.value)
bool(exists)
end
|
Check whether a function with the given name exists.
@example
function-exists(lighten) => true
@function myfunc { @return "something"; }
function-exists(myfunc) => true
@overload function_exists($name)
@param name [Sass::Script::Value::String] The name of the function to
check or a function reference.
@return [Sass::Script::Value::Bool] Whether the function is defined.
|
function_exists
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def mixin_exists(name)
assert_type name, :String, :name
bool(environment.mixin(name.value))
end
|
Check whether a mixin with the given name exists.
@example
mixin-exists(nonexistent) => false
@mixin red-text { color: red; }
mixin-exists(red-text) => true
@overload mixin_exists($name)
@param name [Sass::Script::Value::String] The name of the mixin to
check.
@return [Sass::Script::Value::Bool] Whether the mixin is defined.
|
mixin_exists
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def content_exists
# frames.last is the stack frame for this function,
# so we use frames[-2] to get the frame before that.
mixin_frame = environment.stack.frames[-2]
unless mixin_frame && mixin_frame.type == :mixin
raise Sass::SyntaxError.new("Cannot call content-exists() except within a mixin.")
end
bool(!environment.caller.content.nil?)
end
|
Check whether a mixin was passed a content block.
Unless `content-exists()` is called directly from a mixin, an error will be raised.
@example
@mixin needs-content {
@if not content-exists() {
@error "You must pass a content block!"
}
@content;
}
@overload content_exists()
@return [Sass::Script::Value::Bool] Whether a content block was passed to the mixin.
|
content_exists
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def inspect(value)
value.check_deprecated_interp if value.is_a?(Sass::Script::Value::String)
unquoted_string(value.to_sass)
end
|
Return a string containing the value as its Sass representation.
@overload inspect($value)
@param $value [Sass::Script::Value::Base] The value to inspect.
@return [Sass::Script::Value::String] A representation of the value as
it would be written in Sass.
|
inspect
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def selector_parse(selector)
parse_selector(selector, :selector).to_sass_script
end
|
Parses a user-provided selector into a list of lists of strings
as returned by `&`.
@example
selector-parse(".foo .bar, .baz .bang") => ('.foo' '.bar', '.baz' '.bang')
@overload selector_parse($selector)
@param $selector [Sass::Script::Value::String, Sass::Script::Value::List]
The selector to parse. This can be either a string, a list of
strings, or a list of lists of strings as returned by `&`.
@return [Sass::Script::Value::List]
A list of lists of strings representing `$selector`. This is
in the same format as a selector returned by `&`.
|
selector_parse
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def selector_nest(*selectors)
if selectors.empty?
raise ArgumentError.new("$selectors: At least one selector must be passed")
end
parsed = [parse_selector(selectors.first, :selectors)]
parsed += selectors[1..-1].map {|sel| parse_selector(sel, :selectors, true)}
parsed.inject {|result, child| child.resolve_parent_refs(result)}.to_sass_script
end
|
Return a new selector with all selectors in `$selectors` nested beneath
one another as though they had been nested in the stylesheet as
`$selector1 { $selector2 { ... } }`.
Unlike most selector functions, `selector-nest` allows the
parent selector `&` to be used in any selector but the first.
@example
selector-nest(".foo", ".bar", ".baz") => .foo .bar .baz
selector-nest(".a .foo", ".b .bar") => .a .foo .b .bar
selector-nest(".foo", "&.bar") => .foo.bar
@overload selector_nest($selectors...)
@param $selectors [[Sass::Script::Value::String, Sass::Script::Value::List]]
The selectors to nest. At least one selector must be passed. Each of
these can be either a string, a list of strings, or a list of lists of
strings as returned by `&`.
@return [Sass::Script::Value::List]
A list of lists of strings representing the result of nesting
`$selectors`. This is in the same format as a selector returned by
`&`.
|
selector_nest
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def selector_append(*selectors)
if selectors.empty?
raise ArgumentError.new("$selectors: At least one selector must be passed")
end
selectors.map {|sel| parse_selector(sel, :selectors)}.inject do |parent, child|
child.members.each do |seq|
sseq = seq.members.first
unless sseq.is_a?(Sass::Selector::SimpleSequence)
raise ArgumentError.new("Can't append \"#{seq}\" to \"#{parent}\"")
end
base = sseq.base
case base
when Sass::Selector::Universal
raise ArgumentError.new("Can't append \"#{seq}\" to \"#{parent}\"")
when Sass::Selector::Element
unless base.namespace.nil?
raise ArgumentError.new("Can't append \"#{seq}\" to \"#{parent}\"")
end
sseq.members[0] = Sass::Selector::Parent.new(base.name)
else
sseq.members.unshift Sass::Selector::Parent.new
end
end
child.resolve_parent_refs(parent)
end.to_sass_script
end
|
Return a new selector with all selectors in `$selectors` appended one
another as though they had been nested in the stylesheet as `$selector1 {
&$selector2 { ... } }`.
@example
selector-append(".foo", ".bar", ".baz") => .foo.bar.baz
selector-append(".a .foo", ".b .bar") => "a .foo.b .bar"
selector-append(".foo", "-suffix") => ".foo-suffix"
@overload selector_append($selectors...)
@param $selectors [[Sass::Script::Value::String, Sass::Script::Value::List]]
The selectors to append. At least one selector must be passed. Each of
these can be either a string, a list of strings, or a list of lists of
strings as returned by `&`.
@return [Sass::Script::Value::List]
A list of lists of strings representing the result of appending
`$selectors`. This is in the same format as a selector returned by
`&`.
@raise [ArgumentError] if a selector could not be appended.
|
selector_append
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def selector_extend(selector, extendee, extender)
selector = parse_selector(selector, :selector)
extendee = parse_selector(extendee, :extendee)
extender = parse_selector(extender, :extender)
extends = Sass::Util::SubsetMap.new
begin
extender.populate_extends(extends, extendee, nil, [], true)
selector.do_extend(extends).to_sass_script
rescue Sass::SyntaxError => e
raise ArgumentError.new(e.to_s)
end
end
|
Returns a new version of `$selector` with `$extendee` extended
with `$extender`. This works just like the result of
$selector { ... }
$extender { @extend $extendee }
@example
selector-extend(".a .b", ".b", ".foo .bar") => .a .b, .a .foo .bar, .foo .a .bar
@overload selector_extend($selector, $extendee, $extender)
@param $selector [Sass::Script::Value::String, Sass::Script::Value::List]
The selector within which `$extendee` is extended with
`$extender`. This can be either a string, a list of strings,
or a list of lists of strings as returned by `&`.
@param $extendee [Sass::Script::Value::String, Sass::Script::Value::List]
The selector being extended. This can be either a string, a
list of strings, or a list of lists of strings as returned
by `&`.
@param $extender [Sass::Script::Value::String, Sass::Script::Value::List]
The selector being injected into `$selector`. This can be
either a string, a list of strings, or a list of lists of
strings as returned by `&`.
@return [Sass::Script::Value::List]
A list of lists of strings representing the result of the
extension. This is in the same format as a selector returned
by `&`.
@raise [ArgumentError] if the extension fails
|
selector_extend
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def selector_replace(selector, original, replacement)
selector = parse_selector(selector, :selector)
original = parse_selector(original, :original)
replacement = parse_selector(replacement, :replacement)
extends = Sass::Util::SubsetMap.new
begin
replacement.populate_extends(extends, original, nil, [], true)
selector.do_extend(extends, [], true).to_sass_script
rescue Sass::SyntaxError => e
raise ArgumentError.new(e.to_s)
end
end
|
Replaces all instances of `$original` with `$replacement` in `$selector`
This works by using `@extend` and throwing away the original
selector. This means that it can be used to do very advanced
replacements; see the examples below.
@example
selector-replace(".foo .bar", ".bar", ".baz") => ".foo .baz"
selector-replace(".foo.bar.baz", ".foo.baz", ".qux") => ".bar.qux"
@overload selector_replace($selector, $original, $replacement)
@param $selector [Sass::Script::Value::String, Sass::Script::Value::List]
The selector within which `$original` is replaced with
`$replacement`. This can be either a string, a list of
strings, or a list of lists of strings as returned by `&`.
@param $original [Sass::Script::Value::String, Sass::Script::Value::List]
The selector being replaced. This can be either a string, a
list of strings, or a list of lists of strings as returned
by `&`.
@param $replacement [Sass::Script::Value::String, Sass::Script::Value::List]
The selector that `$original` is being replaced with. This
can be either a string, a list of strings, or a list of
lists of strings as returned by `&`.
@return [Sass::Script::Value::List]
A list of lists of strings representing the result of the
extension. This is in the same format as a selector returned
by `&`.
@raise [ArgumentError] if the replacement fails
|
selector_replace
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def selector_unify(selector1, selector2)
selector1 = parse_selector(selector1, :selector1)
selector2 = parse_selector(selector2, :selector2)
return null unless (unified = selector1.unify(selector2))
unified.to_sass_script
end
|
Unifies two selectors into a single selector that matches only
elements matched by both input selectors. Returns `null` if
there is no such selector.
Like the selector unification done for `@extend`, this doesn't
guarantee that the output selector will match *all* elements
matched by both input selectors. For example, if `.a .b` is
unified with `.x .y`, `.a .x .b.y, .x .a .b.y` will be returned,
but `.a.x .b.y` will not. This avoids exponential output size
while matching all elements that are likely to exist in
practice.
@example
selector-unify(".a", ".b") => .a.b
selector-unify(".a .b", ".x .y") => .a .x .b.y, .x .a .b.y
selector-unify(".a.b", ".b.c") => .a.b.c
selector-unify("#a", "#b") => null
@overload selector_unify($selector1, $selector2)
@param $selector1 [Sass::Script::Value::String, Sass::Script::Value::List]
The first selector to be unified. This can be either a
string, a list of strings, or a list of lists of strings as
returned by `&`.
@param $selector2 [Sass::Script::Value::String, Sass::Script::Value::List]
The second selector to be unified. This can be either a
string, a list of strings, or a list of lists of strings as
returned by `&`.
@return [Sass::Script::Value::List, Sass::Script::Value::Null]
A list of lists of strings representing the result of the
unification, or null if no unification exists. This is in
the same format as a selector returned by `&`.
|
selector_unify
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def simple_selectors(selector)
selector = parse_compound_selector(selector, :selector)
list(selector.members.map {|simple| unquoted_string(simple.to_s)}, :comma)
end
|
Returns the [simple
selectors](http://dev.w3.org/csswg/selectors4/#simple) that
comprise the compound selector `$selector`.
Note that `$selector` **must be** a [compound
selector](http://dev.w3.org/csswg/selectors4/#compound). That
means it cannot contain commas or spaces. It also means that
unlike other selector functions, this takes only strings, not
lists.
@example
simple-selectors(".foo.bar") => ".foo", ".bar"
simple-selectors(".foo.bar.baz") => ".foo", ".bar", ".baz"
@overload simple_selectors($selector)
@param $selector [Sass::Script::Value::String]
The compound selector whose simple selectors will be extracted.
@return [Sass::Script::Value::List]
A list of simple selectors in the compound selector.
|
simple_selectors
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def is_superselector(sup, sub)
sup = parse_selector(sup, :super)
sub = parse_selector(sub, :sub)
bool(sup.superselector?(sub))
end
|
Returns whether `$super` is a superselector of `$sub`. This means that
`$super` matches all the elements that `$sub` matches, as well as possibly
additional elements. In general, simpler selectors tend to be
superselectors of more complex oned.
@example
is-superselector(".foo", ".foo.bar") => true
is-superselector(".foo.bar", ".foo") => false
is-superselector(".bar", ".foo .bar") => true
is-superselector(".foo .bar", ".bar") => false
@overload is_superselector($super, $sub)
@param $super [Sass::Script::Value::String, Sass::Script::Value::List]
The potential superselector. This can be either a string, a list of
strings, or a list of lists of strings as returned by `&`.
@param $sub [Sass::Script::Value::String, Sass::Script::Value::List]
The potential subselector. This can be either a string, a list of
strings, or a list of lists of strings as returned by `&`.
@return [Sass::Script::Value::Bool]
Whether `$selector1` is a superselector of `$selector2`.
|
is_superselector
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def numeric_transformation(value)
assert_type value, :Number, :value
Sass::Script::Value::Number.new(
yield(value.value), value.numerator_units, value.denominator_units)
end
|
This method implements the pattern of transforming a numeric value into
another numeric value with the same units.
It yields a number to a block to perform the operation and return a number
|
numeric_transformation
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/functions.rb
|
Apache-2.0
|
def line
return @line unless @tok
@tok.source_range.start_pos.line
end
|
The line number of the lexer's current position.
@return [Integer]
|
line
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
Apache-2.0
|
def offset
return @offset unless @tok
@tok.source_range.start_pos.offset
end
|
The number of bytes into the current line
of the lexer's current position (1-based).
@return [Integer]
|
offset
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
Apache-2.0
|
def initialize(str, line, offset, options)
@scanner = str.is_a?(StringScanner) ? str : Sass::Util::MultibyteStringScanner.new(str)
@line = line
@offset = offset
@options = options
@interpolation_stack = []
@prev = nil
@tok = nil
@next_tok = nil
end
|
@param str [String, StringScanner] The source text to lex
@param line [Integer] The 1-based line on which the SassScript appears.
Used for error reporting and sourcemap building
@param offset [Integer] The 1-based character (not byte) offset in the line in the source.
Used for error reporting and sourcemap building
@param options [{Symbol => Object}] An options hash;
see {file:SASS_REFERENCE.md#Options the Sass options documentation}
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
Apache-2.0
|
def next
@tok ||= read_token
@tok, tok = nil, @tok
@prev = tok
tok
end
|
Moves the lexer forward one token.
@return [Token] The token that was moved past
|
next
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
Apache-2.0
|
def whitespace?(tok = @tok)
if tok
@scanner.string[0...tok.pos] =~ /\s\Z/
else
@scanner.string[@scanner.pos, 1] =~ /^\s/ ||
@scanner.string[@scanner.pos - 1, 1] =~ /\s\Z/
end
end
|
Returns whether or not there's whitespace before the next token.
@return [Boolean]
|
whitespace?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
Apache-2.0
|
def char(pos = @scanner.pos)
@scanner.string[pos, 1]
end
|
Returns the given character.
@return [String]
|
char
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
Apache-2.0
|
def next_char
unpeek!
scan(/./)
end
|
Consumes and returns single raw character from the input stream.
@return [String]
|
next_char
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
Apache-2.0
|
def peek
@tok ||= read_token
end
|
Returns the next token without moving the lexer forward.
@return [Token] The next token
|
peek
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
Apache-2.0
|
def unpeek!
raise "[BUG] Can't unpeek before a queued token!" if @next_tok
return unless @tok
@scanner.pos = @tok.pos
@line = @tok.source_range.start_pos.line
@offset = @tok.source_range.start_pos.offset
end
|
Rewinds the underlying StringScanner
to before the token returned by \{#peek}.
|
unpeek!
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
Apache-2.0
|
def done?
return if @next_tok
whitespace unless after_interpolation? && !@interpolation_stack.empty?
@scanner.eos? && @tok.nil?
end
|
@return [Boolean] Whether or not there's more source text to lex.
|
done?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
Apache-2.0
|
def after_interpolation?
@prev && @prev.type == :end_interpolation
end
|
@return [Boolean] Whether or not the last token lexed was `:end_interpolation`.
|
after_interpolation?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
Apache-2.0
|
def expected!(name)
unpeek!
Sass::SCSS::Parser.expected(@scanner, name, @line)
end
|
Raise an error to the effect that `name` was expected in the input stream
and wasn't found.
This calls \{#unpeek!} to rewind the scanner to immediately after
the last returned token.
@param name [String] The name of the entity that was expected but not found
@raise [Sass::SyntaxError]
|
expected!
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
Apache-2.0
|
def str
old_pos = @tok ? @tok.pos : @scanner.pos
yield
new_pos = @tok ? @tok.pos : @scanner.pos
@scanner.string[old_pos...new_pos]
end
|
Records all non-comment text the lexer consumes within the block
and returns it as a string.
@yield A block in which text is recorded
@return [String]
|
str
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
Apache-2.0
|
def try
old_pos = @scanner.pos
old_line = @line
old_offset = @offset
old_interpolation_stack = @interpolation_stack.dup
old_prev = @prev
old_tok = @tok
old_next_tok = @next_tok
result = yield
return result if result
@scanner.pos = old_pos
@line = old_line
@offset = old_offset
@interpolation_stack = old_interpolation_stack
@prev = old_prev
@tok = old_tok
@next_tok = old_next_tok
nil
end
|
Runs a block, and rewinds the state of the lexer to the beginning of the
block if it returns `nil` or `false`.
|
try
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/lexer.rb
|
Apache-2.0
|
def initialize(str, line, offset, options = {})
@options = options
@allow_extra_text = options.delete(:allow_extra_text)
@lexer = lexer_class.new(str, line, offset, options)
@stop_at = nil
end
|
@param str [String, StringScanner] The source text to parse
@param line [Integer] The line on which the SassScript appears.
Used for error reporting and sourcemap building
@param offset [Integer] The character (not byte) offset where the script starts in the line.
Used for error reporting and sourcemap building
@param options [{Symbol => Object}] An options hash; see
{file:SASS_REFERENCE.md#Options the Sass options documentation}.
This supports an additional `:allow_extra_text` option that controls
whether the parser throws an error when extra text is encountered
after the parsed construct.
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
Apache-2.0
|
def parse_interpolated(warn_for_color = false)
# Start two characters back to compensate for #{
start_pos = Sass::Source::Position.new(line, offset - 2)
expr = assert_expr :expr
assert_tok :end_interpolation
expr = Sass::Script::Tree::Interpolation.new(
nil, expr, nil, false, false, :warn_for_color => warn_for_color)
check_for_interpolation expr
expr.options = @options
node(expr, start_pos)
rescue Sass::SyntaxError => e
e.modify_backtrace :line => @lexer.line, :filename => @options[:filename]
raise e
end
|
Parses a SassScript expression within an interpolated segment (`#{}`).
This means that it stops when it comes across an unmatched `}`,
which signals the end of an interpolated segment,
it returns rather than throwing an error.
@param warn_for_color [Boolean] Whether raw color values passed to
interoplation should cause a warning.
@return [Script::Tree::Node] The root node of the parse tree
@raise [Sass::SyntaxError] if the expression isn't valid SassScript
|
parse_interpolated
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
Apache-2.0
|
def parse
expr = assert_expr :expr
assert_done
expr.options = @options
check_for_interpolation expr
expr
rescue Sass::SyntaxError => e
e.modify_backtrace :line => @lexer.line, :filename => @options[:filename]
raise e
end
|
Parses a SassScript expression.
@return [Script::Tree::Node] The root node of the parse tree
@raise [Sass::SyntaxError] if the expression isn't valid SassScript
|
parse
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
Apache-2.0
|
def parse_mixin_include_arglist
args, keywords = [], {}
if try_tok(:lparen)
args, keywords, splat, kwarg_splat = mixin_arglist
assert_tok(:rparen)
end
assert_done
args.each do |a|
check_for_interpolation a
a.options = @options
end
keywords.each do |_, v|
check_for_interpolation v
v.options = @options
end
if splat
check_for_interpolation splat
splat.options = @options
end
if kwarg_splat
check_for_interpolation kwarg_splat
kwarg_splat.options = @options
end
return args, keywords, splat, kwarg_splat
rescue Sass::SyntaxError => e
e.modify_backtrace :line => @lexer.line, :filename => @options[:filename]
raise e
end
|
Parses the argument list for a mixin include.
@return [(Array<Script::Tree::Node>,
{String => Script::Tree::Node},
Script::Tree::Node,
Script::Tree::Node)]
The root nodes of the positional arguments, keyword arguments, and
splat argument(s). Keyword arguments are in a hash from names to values.
@raise [Sass::SyntaxError] if the argument list isn't valid SassScript
|
parse_mixin_include_arglist
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
Apache-2.0
|
def parse_mixin_definition_arglist
args, splat = defn_arglist!(false)
assert_done
args.each do |k, v|
check_for_interpolation k
k.options = @options
if v
check_for_interpolation v
v.options = @options
end
end
if splat
check_for_interpolation splat
splat.options = @options
end
return args, splat
rescue Sass::SyntaxError => e
e.modify_backtrace :line => @lexer.line, :filename => @options[:filename]
raise e
end
|
Parses the argument list for a mixin definition.
@return [(Array<Script::Tree::Node>, Script::Tree::Node)]
The root nodes of the arguments, and the splat argument.
@raise [Sass::SyntaxError] if the argument list isn't valid SassScript
|
parse_mixin_definition_arglist
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
Apache-2.0
|
def parse_function_definition_arglist
args, splat = defn_arglist!(true)
assert_done
args.each do |k, v|
check_for_interpolation k
k.options = @options
if v
check_for_interpolation v
v.options = @options
end
end
if splat
check_for_interpolation splat
splat.options = @options
end
return args, splat
rescue Sass::SyntaxError => e
e.modify_backtrace :line => @lexer.line, :filename => @options[:filename]
raise e
end
|
Parses the argument list for a function definition.
@return [(Array<Script::Tree::Node>, Script::Tree::Node)]
The root nodes of the arguments, and the splat argument.
@raise [Sass::SyntaxError] if the argument list isn't valid SassScript
|
parse_function_definition_arglist
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
Apache-2.0
|
def parse_string
unless (peek = @lexer.peek) &&
(peek.type == :string ||
(peek.type == :funcall && peek.value.downcase == 'url'))
lexer.expected!("string")
end
expr = assert_expr :funcall
check_for_interpolation expr
expr.options = @options
@lexer.unpeek!
expr
rescue Sass::SyntaxError => e
e.modify_backtrace :line => @lexer.line, :filename => @options[:filename]
raise e
end
|
Parse a single string value, possibly containing interpolation.
Doesn't assert that the scanner is finished after parsing.
@return [Script::Tree::Node] The root node of the parse tree.
@raise [Sass::SyntaxError] if the string isn't valid SassScript
|
parse_string
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
Apache-2.0
|
def precedence_of(op)
PRECEDENCE.each_with_index do |e, i|
return i if Array(e).include?(op)
end
raise "[BUG] Unknown operator #{op.inspect}"
end
|
Returns an integer representing the precedence
of the given operator.
A lower integer indicates a looser binding.
@private
|
precedence_of
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
Apache-2.0
|
def production(name, sub, *ops)
class_eval <<RUBY, __FILE__, __LINE__ + 1
def #{name}
interp = try_ops_after_interp(#{ops.inspect}, #{name.inspect})
return interp if interp
return unless e = #{sub}
while tok = peek_toks(#{ops.map {|o| o.inspect}.join(', ')})
return e if @stop_at && @stop_at.include?(tok.type)
@lexer.next
if interp = try_op_before_interp(tok, e)
other_interp = try_ops_after_interp(#{ops.inspect}, #{name.inspect}, interp)
return interp unless other_interp
return other_interp
end
e = node(Tree::Operation.new(e, assert_expr(#{sub.inspect}), tok.type),
e.source_range.start_pos)
end
e
end
RUBY
end
|
Defines a simple left-associative production.
name is the name of the production,
sub is the name of the production beneath it,
and ops is a list of operators for this precedence level
|
production
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
Apache-2.0
|
def is_unsafe_before?(expr, char_before)
return char_before == ')' if is_safe_value?(expr)
# Otherwise, it's only safe if it was another interpolation.
!expr.is_a?(Script::Tree::Interpolation)
end
|
Returns whether `expr` is unsafe to include before an interpolation.
@param expr [Node] The expression to check.
@param char_before [String] The character immediately before the
interpolation being checked (and presumably the last character of
`expr`).
@return [Boolean]
|
is_unsafe_before?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
Apache-2.0
|
def is_safe_value?(expr)
return is_safe_value?(expr.elements.last) if expr.is_a?(Script::Tree::ListLiteral)
return false unless expr.is_a?(Script::Tree::Literal)
expr.value.is_a?(Script::Value::Number) ||
(expr.value.is_a?(Script::Value::String) && expr.value.type == :identifier)
end
|
Returns whether `expr` is safe as the value immediately before an
interpolation.
It's safe as long as the previous expression is an identifier or number,
or a list whose last element is also safe.
|
is_safe_value?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
Apache-2.0
|
def literal_node(value, source_range_or_start_pos, end_pos = source_position)
node(Sass::Script::Tree::Literal.new(value), source_range_or_start_pos, end_pos)
end
|
@overload node(value, source_range)
@param value [Sass::Script::Value::Base]
@param source_range [Sass::Source::Range]
@overload node(value, start_pos, end_pos = source_position)
@param value [Sass::Script::Value::Base]
@param start_pos [Sass::Source::Position]
@param end_pos [Sass::Source::Position]
|
literal_node
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
Apache-2.0
|
def node(node, source_range_or_start_pos, end_pos = source_position)
source_range =
if source_range_or_start_pos.is_a?(Sass::Source::Range)
source_range_or_start_pos
else
range(source_range_or_start_pos, end_pos)
end
node.line = source_range.start_pos.line
node.source_range = source_range
node.filename = @options[:filename]
node
end
|
@overload node(node, source_range)
@param node [Sass::Script::Tree::Node]
@param source_range [Sass::Source::Range]
@overload node(node, start_pos, end_pos = source_position)
@param node [Sass::Script::Tree::Node]
@param start_pos [Sass::Source::Position]
@param end_pos [Sass::Source::Position]
|
node
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
Apache-2.0
|
def array_to_interpolation(array)
Sass::Util.merge_adjacent_strings(array).reverse.inject(nil) do |after, value|
if value.is_a?(::String)
literal = Sass::Script::Tree::Literal.new(
Sass::Script::Value::String.new(value))
next literal unless after
Sass::Script::Tree::StringInterpolation.new(literal, after.mid, after.after)
else
Sass::Script::Tree::StringInterpolation.new(
Sass::Script::Tree::Literal.new(
Sass::Script::Value::String.new('')),
value,
after || Sass::Script::Tree::Literal.new(
Sass::Script::Value::String.new('')))
end
end
end
|
Converts an array of strings and expressions to a string interoplation
object.
@param array [Array<Script::Tree:Node | String>]
@return [Script::Tree::StringInterpolation]
|
array_to_interpolation
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/parser.rb
|
Apache-2.0
|
def initialize(name_or_callable, args, keywords, splat, kwarg_splat)
if name_or_callable.is_a?(Sass::Callable)
@callable = name_or_callable
@name = name_or_callable.name
else
@callable = nil
@name = name_or_callable
end
@args = args
@keywords = keywords
@splat = splat
@kwarg_splat = kwarg_splat
super()
end
|
@param name_or_callable [String, Sass::Callable] See \{#name}
@param args [Array<Node>] See \{#args}
@param keywords [Sass::Util::NormalizedMap<Node>] See \{#keywords}
@param splat [Node] See \{#splat}
@param kwarg_splat [Node] See \{#kwarg_splat}
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/funcall.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/funcall.rb
|
Apache-2.0
|
def inspect
args = @args.map {|a| a.inspect}.join(', ')
keywords = @keywords.as_stored.to_a.map {|k, v| "$#{k}: #{v.inspect}"}.join(', ')
if self.splat
splat = args.empty? && keywords.empty? ? "" : ", "
splat = "#{splat}#{self.splat.inspect}..."
splat = "#{splat}, #{kwarg_splat.inspect}..." if kwarg_splat
end
"#{name}(#{args}#{', ' unless args.empty? || keywords.empty?}#{keywords}#{splat})"
end
|
@return [String] A string representation of the function call
|
inspect
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/funcall.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/funcall.rb
|
Apache-2.0
|
def children
res = @args + @keywords.values
res << @splat if @splat
res << @kwarg_splat if @kwarg_splat
res
end
|
Returns the arguments to the function.
@return [Array<Node>]
@see Node#children
|
children
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/funcall.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/funcall.rb
|
Apache-2.0
|
def _perform(environment)
args = @args.each_with_index.
map {|a, i| perform_arg(a, environment, signature && signature.args[i])}
keywords = Sass::Util.map_hash(@keywords) do |k, v|
[k, perform_arg(v, environment, k.tr('-', '_'))]
end
splat = Sass::Tree::Visitors::Perform.perform_splat(
@splat, keywords, @kwarg_splat, environment)
fn = @callable || environment.function(@name)
if fn && fn.origin == :stylesheet
environment.stack.with_function(filename, line, name) do
return without_original(perform_sass_fn(fn, args, splat, environment))
end
end
args = construct_ruby_args(ruby_name, args, splat, environment)
if Sass::Script::Functions.callable?(ruby_name) && (!fn || fn.origin == :builtin)
local_environment = Sass::Environment.new(environment.global_env, environment.options)
local_environment.caller = Sass::ReadOnlyEnvironment.new(environment, environment.options)
result = local_environment.stack.with_function(filename, line, name) do
opts(Sass::Script::Functions::EvaluationContext.new(
local_environment).send(ruby_name, *args))
end
without_original(result)
else
opts(to_literal(args))
end
rescue ArgumentError => e
reformat_argument_error(e)
end
|
Evaluates the function call.
@param environment [Sass::Environment] The environment in which to evaluate the SassScript
@return [Sass::Script::Value] The SassScript object that is the value of the function call
@raise [Sass::SyntaxError] if the function call raises an ArgumentError
|
_perform
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/funcall.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/funcall.rb
|
Apache-2.0
|
def to_value(args)
Sass::Script::Value::String.new("#{name}(#{args.join(', ')})")
end
|
This method is factored out from `_perform` so that compass can override
it with a cross-browser implementation for functions that require vendor prefixes
in the generated css.
|
to_value
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/funcall.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/funcall.rb
|
Apache-2.0
|
def initialize(before, mid, after, wb, wa, opts = {})
@before = before
@mid = mid
@after = after
@whitespace_before = wb
@whitespace_after = wa
@originally_text = opts[:originally_text] || false
@warn_for_color = opts[:warn_for_color] || false
@deprecation = opts[:deprecation] || :none
end
|
Interpolation in a property is of the form `before #{mid} after`.
@param before [Node] See {Interpolation#before}
@param mid [Node] See {Interpolation#mid}
@param after [Node] See {Interpolation#after}
@param wb [Boolean] See {Interpolation#whitespace_before}
@param wa [Boolean] See {Interpolation#whitespace_after}
@param originally_text [Boolean] See {Interpolation#originally_text}
@param warn_for_color [Boolean] See {Interpolation#warn_for_color}
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/interpolation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/interpolation.rb
|
Apache-2.0
|
def inspect
"(interpolation #{@before.inspect} #{@mid.inspect} #{@after.inspect})"
end
|
@return [String] A human-readable s-expression representation of the interpolation
|
inspect
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/interpolation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/interpolation.rb
|
Apache-2.0
|
def to_quoted_equivalent
Funcall.new(
"unquote",
[to_string_interpolation(self)],
Sass::Util::NormalizedMap.new,
nil,
nil)
end
|
Returns an `unquote()` expression that will evaluate to the same value as
this interpolation.
@return [Sass::Script::Tree::Node]
|
to_quoted_equivalent
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/interpolation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/interpolation.rb
|
Apache-2.0
|
def children
[@before, @mid, @after].compact
end
|
Returns the three components of the interpolation, `before`, `mid`, and `after`.
@return [Array<Node>]
@see #initialize
@see Node#children
|
children
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/interpolation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/interpolation.rb
|
Apache-2.0
|
def to_string_interpolation(node_or_interp)
unless node_or_interp.is_a?(Interpolation)
node = node_or_interp
return string_literal(node.value.to_s) if node.is_a?(Literal)
if node.is_a?(StringInterpolation)
return concat(string_literal(node.quote), concat(node, string_literal(node.quote)))
end
return StringInterpolation.new(string_literal(""), node, string_literal(""))
end
interp = node_or_interp
after_string_or_interp =
if interp.after
to_string_interpolation(interp.after)
else
string_literal("")
end
if interp.after && interp.whitespace_after
after_string_or_interp = concat(string_literal(' '), after_string_or_interp)
end
mid_string_or_interp = to_string_interpolation(interp.mid)
before_string_or_interp =
if interp.before
to_string_interpolation(interp.before)
else
string_literal("")
end
if interp.before && interp.whitespace_before
before_string_or_interp = concat(before_string_or_interp, string_literal(' '))
end
concat(before_string_or_interp, concat(mid_string_or_interp, after_string_or_interp))
end
|
Converts a script node into a corresponding string interpolation
expression.
@param node_or_interp [Sass::Script::Tree::Node]
@return [Sass::Script::Tree::StringInterpolation]
|
to_string_interpolation
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/interpolation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/interpolation.rb
|
Apache-2.0
|
def _perform(environment)
res = ""
res << @before.perform(environment).to_s if @before
res << " " if @before && @whitespace_before
val = @mid.perform(environment)
if @warn_for_color && val.is_a?(Sass::Script::Value::Color) && val.name
alternative = Operation.new(Sass::Script::Value::String.new("", :string), @mid, :plus)
Sass::Util.sass_warn <<MESSAGE
WARNING on line #{line}, column #{source_range.start_pos.offset}#{" of #{filename}" if filename}:
You probably don't mean to use the color value `#{val}' in interpolation here.
It may end up represented as #{val.inspect}, which will likely produce invalid CSS.
Always quote color names when using them as strings (for example, "#{val}").
If you really want to use the color value here, use `#{alternative.to_sass}'.
MESSAGE
end
res << val.to_s(:quote => :none)
res << " " if @after && @whitespace_after
res << @after.perform(environment).to_s if @after
str = Sass::Script::Value::String.new(
res, :identifier,
(to_quoted_equivalent.to_sass if deprecation == :potential))
str.source_range = source_range
opts(str)
end
|
Evaluates the interpolation.
@param environment [Sass::Environment] The environment in which to evaluate the SassScript
@return [Sass::Script::Value::String]
The SassScript string that is the value of the interpolation
|
_perform
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/interpolation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/interpolation.rb
|
Apache-2.0
|
def concat(string_or_interp1, string_or_interp2)
if string_or_interp1.is_a?(Literal) && string_or_interp2.is_a?(Literal)
return string_literal(string_or_interp1.value.value + string_or_interp2.value.value)
end
if string_or_interp1.is_a?(Literal)
string = string_or_interp1
interp = string_or_interp2
before = string_literal(string.value.value + interp.before.value.value)
return StringInterpolation.new(before, interp.mid, interp.after)
end
StringInterpolation.new(
string_or_interp1.before,
string_or_interp1.mid,
concat(string_or_interp1.after, string_or_interp2))
end
|
Concatenates two string literals or string interpolation expressions.
@param string_or_interp1 [Sass::Script::Tree::Literal|Sass::Script::Tree::StringInterpolation]
@param string_or_interp2 [Sass::Script::Tree::Literal|Sass::Script::Tree::StringInterpolation]
@return [Sass::Script::Tree::StringInterpolation]
|
concat
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/interpolation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/interpolation.rb
|
Apache-2.0
|
def string_literal(string)
Literal.new(Sass::Script::Value::String.new(string, :string))
end
|
Returns a string literal with the given contents.
@param string [String]
@return string [Sass::Script::Tree::Literal]
|
string_literal
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/interpolation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/interpolation.rb
|
Apache-2.0
|
def initialize(elements, separator: nil, bracketed: false)
@elements = elements
@separator = separator
@bracketed = bracketed
end
|
Creates a new list literal.
@param elements [Array<Node>] See \{#elements}
@param separator [Symbol] See \{#separator}
@param bracketed [Boolean] See \{#bracketed}
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/list_literal.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/list_literal.rb
|
Apache-2.0
|
def element_needs_parens?(element)
if element.is_a?(ListLiteral)
return false if element.elements.length < 2
return false if element.bracketed
return Sass::Script::Parser.precedence_of(element.separator || :space) <=
Sass::Script::Parser.precedence_of(separator || :space)
end
return false unless separator == :space
if element.is_a?(UnaryOperation)
return element.operator == :minus || element.operator == :plus
end
return false unless element.is_a?(Operation)
return true unless element.operator == :div
!(is_literal_number?(element.operand1) && is_literal_number?(element.operand2))
end
|
Returns whether an element in the list should be wrapped in parentheses
when serialized to Sass.
|
element_needs_parens?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/list_literal.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/list_literal.rb
|
Apache-2.0
|
def is_literal_number?(value)
value.is_a?(Literal) &&
value.value.is_a?((Sass::Script::Value::Number)) &&
!value.value.original.nil?
end
|
Returns whether a value is a number literal that shouldn't be divided.
|
is_literal_number?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/list_literal.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/list_literal.rb
|
Apache-2.0
|
def initialize(value)
@value = value
end
|
Creates a new literal value.
@param value [Sass::Script::Value::Base]
@see #value
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/literal.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/literal.rb
|
Apache-2.0
|
def initialize(pairs)
@pairs = pairs
end
|
Creates a new map literal.
@param pairs [Array<(Node, Node)>] See \{#pairs}
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/map_literal.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/map_literal.rb
|
Apache-2.0
|
def perform(environment)
_perform(environment)
rescue Sass::SyntaxError => e
e.modify_backtrace(:line => line)
raise e
end
|
Evaluates the node.
\{#perform} shouldn't be overridden directly;
instead, override \{#\_perform}.
@param environment [Sass::Environment] The environment in which to evaluate the SassScript
@return [Sass::Script::Value] The SassScript object that is the value of the SassScript
|
perform
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/node.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/node.rb
|
Apache-2.0
|
def force_division!
children.each {|c| c.force_division!}
end
|
Forces any division operations with number literals in this expression to
do real division, rather than returning strings.
|
force_division!
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/node.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/node.rb
|
Apache-2.0
|
def dasherize(s, opts)
if opts[:dasherize]
s.tr('_', '-')
else
s
end
end
|
Converts underscores to dashes if the :dasherize option is set.
|
dasherize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/node.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/node.rb
|
Apache-2.0
|
def opts(value)
value.options = options
value
end
|
Sets the \{#options} field on the given value and returns it.
@param value [Sass::Script::Value]
@return [Sass::Script::Value]
|
opts
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/node.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/node.rb
|
Apache-2.0
|
def initialize(operand1, operand2, operator)
@operand1 = operand1
@operand2 = operand2
@operator = operator
super()
end
|
@param operand1 [Sass::Script::Tree::Node] The parse-tree node
for the right-hand side of the operator
@param operand2 [Sass::Script::Tree::Node] The parse-tree node
for the left-hand side of the operator
@param operator [Symbol] The operator to perform.
This should be one of the binary operator names in {Sass::Script::Lexer::OPERATORS}
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/operation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/operation.rb
|
Apache-2.0
|
def inspect
"(#{@operator.inspect} #{@operand1.inspect} #{@operand2.inspect})"
end
|
@return [String] A human-readable s-expression representation of the operation
|
inspect
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/operation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/operation.rb
|
Apache-2.0
|
def children
[@operand1, @operand2]
end
|
Returns the operands for this operation.
@return [Array<Node>]
@see Node#children
|
children
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/operation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/operation.rb
|
Apache-2.0
|
def _perform(environment)
value1 = @operand1.perform(environment)
# Special-case :and and :or to support short-circuiting.
if @operator == :and
return value1.to_bool ? @operand2.perform(environment) : value1
elsif @operator == :or
return value1.to_bool ? value1 : @operand2.perform(environment)
end
value2 = @operand2.perform(environment)
if (value1.is_a?(Sass::Script::Value::Null) || value2.is_a?(Sass::Script::Value::Null)) &&
@operator != :eq && @operator != :neq
raise Sass::SyntaxError.new(
"Invalid null operation: \"#{value1.inspect} #{@operator} #{value2.inspect}\".")
end
begin
result = opts(value1.send(@operator, value2))
rescue NoMethodError => e
raise e unless e.name.to_s == @operator.to_s
raise Sass::SyntaxError.new("Undefined operation: \"#{value1} #{@operator} #{value2}\".")
end
warn_for_color_arithmetic(value1, value2)
warn_for_unitless_equals(value1, value2, result)
result
end
|
Evaluates the operation.
@param environment [Sass::Environment] The environment in which to evaluate the SassScript
@return [Sass::Script::Value] The SassScript object that is the value of the operation
@raise [Sass::SyntaxError] if the operation is undefined for the operands
|
_perform
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/operation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/operation.rb
|
Apache-2.0
|
def quote
quote_for(self) || '"'
end
|
Returns the quote character that should be used to wrap a Sass
representation of this interpolation.
|
quote
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/string_interpolation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/string_interpolation.rb
|
Apache-2.0
|
def initialize(before, mid, after)
@before = before
@mid = mid
@after = after
end
|
Interpolation in a string is of the form `"before #{mid} after"`,
where `before` and `after` may include more interpolation.
@param before [StringInterpolation, Literal] See {StringInterpolation#before}
@param mid [Node] See {StringInterpolation#mid}
@param after [Literal] See {StringInterpolation#after}
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/string_interpolation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/string_interpolation.rb
|
Apache-2.0
|
def inspect
"(string_interpolation #{@before.inspect} #{@mid.inspect} #{@after.inspect})"
end
|
@return [String] A human-readable s-expression representation of the interpolation
|
inspect
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/string_interpolation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/string_interpolation.rb
|
Apache-2.0
|
def children
[@before, @mid, @after].compact
end
|
Returns the three components of the interpolation, `before`, `mid`, and `after`.
@return [Array<Node>]
@see #initialize
@see Node#children
|
children
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/string_interpolation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/string_interpolation.rb
|
Apache-2.0
|
def _perform(environment)
res = ""
before = @before.perform(environment)
res << before.value
mid = @mid.perform(environment)
res << (mid.is_a?(Sass::Script::Value::String) ? mid.value : mid.to_s(:quote => :none))
res << @after.perform(environment).value
opts(Sass::Script::Value::String.new(res, before.type))
end
|
Evaluates the interpolation.
@param environment [Sass::Environment] The environment in which to evaluate the SassScript
@return [Sass::Script::Value::String]
The SassScript string that is the value of the interpolation
|
_perform
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/string_interpolation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/string_interpolation.rb
|
Apache-2.0
|
def initialize(operand, operator)
@operand = operand
@operator = operator
super()
end
|
@param operand [Script::Node] See \{#operand}
@param operator [Symbol] See \{#operator}
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/unary_operation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/unary_operation.rb
|
Apache-2.0
|
def inspect
"(#{@operator.inspect} #{@operand.inspect})"
end
|
@return [String] A human-readable s-expression representation of the operation
|
inspect
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/unary_operation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/unary_operation.rb
|
Apache-2.0
|
def _perform(environment)
operator = "unary_#{@operator}"
value = @operand.perform(environment)
value.send(operator)
rescue NoMethodError => e
raise e unless e.name.to_s == operator.to_s
raise Sass::SyntaxError.new("Undefined unary operation: \"#{@operator} #{value}\".")
end
|
Evaluates the operation.
@param environment [Sass::Environment] The environment in which to evaluate the SassScript
@return [Sass::Script::Value] The SassScript object that is the value of the operation
@raise [Sass::SyntaxError] if the operation is undefined for the operand
|
_perform
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/unary_operation.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/unary_operation.rb
|
Apache-2.0
|
def inspect(opts = {})
"$#{dasherize(name, opts)}"
end
|
@return [String] A string representation of the variable
|
inspect
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/variable.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/variable.rb
|
Apache-2.0
|
def _perform(environment)
val = environment.var(name)
raise Sass::SyntaxError.new("Undefined variable: \"$#{name}\".") unless val
if val.is_a?(Sass::Script::Value::Number) && val.original
val = val.dup
val.original = nil
end
val
end
|
Evaluates the variable.
@param environment [Sass::Environment] The environment in which to evaluate the SassScript
@return [Sass::Script::Value] The SassScript object that is the value of the variable
@raise [Sass::SyntaxError] if the variable is undefined
|
_perform
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/variable.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/tree/variable.rb
|
Apache-2.0
|
def initialize(value, keywords, separator)
super(value, separator: separator)
if keywords.is_a?(Sass::Util::NormalizedMap)
@keywords = keywords
else
@keywords = Sass::Util::NormalizedMap.new(keywords)
end
end
|
Creates a new argument list.
@param value [Array<Value>] See \{List#value}.
@param keywords [Hash<String, Value>, NormalizedMap<Value>] See \{#keywords}
@param separator [String] See \{List#separator}.
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/arg_list.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/arg_list.rb
|
Apache-2.0
|
def keywords
@keywords_accessed = true
@keywords
end
|
The keyword arguments attached to this list.
@return [NormalizedMap<Value>]
|
keywords
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/arg_list.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/arg_list.rb
|
Apache-2.0
|
def initialize(value = nil)
value.freeze unless value.nil? || value == true || value == false
@value = value
@options = nil
end
|
Creates a new value.
@param value [Object] The object for \{#value}
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/base.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/base.rb
|
Apache-2.0
|
def options
return @options if @options
raise Sass::SyntaxError.new(<<MSG)
The #options attribute is not set on this #{self.class}.
This error is probably occurring because #to_s was called
on this value within a custom Sass function without first
setting the #options attribute.
MSG
end
|
Returns the options hash for this node.
@return [{Symbol => Object}]
@raise [Sass::SyntaxError] if the options hash hasn't been set.
This should only happen when the value was created
outside of the parser and \{#to\_s} was called on it
|
options
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/base.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/base.rb
|
Apache-2.0
|
def eq(other)
Sass::Script::Value::Bool.new(self.class == other.class && value == other.value)
end
|
The SassScript `==` operation.
**Note that this returns a {Sass::Script::Value::Bool} object,
not a Ruby boolean**.
@param other [Value] The right-hand side of the operator
@return [Sass::Script::Value::Bool] True if this value is the same as the other,
false otherwise
|
eq
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/base.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/base.rb
|
Apache-2.0
|
def plus(other)
type = other.is_a?(Sass::Script::Value::String) ? other.type : :identifier
Sass::Script::Value::String.new(to_s(:quote => :none) + other.to_s(:quote => :none), type)
end
|
The SassScript `+` operation.
@param other [Value] The right-hand side of the operator
@return [Script::Value::String] A string containing both values
without any separation
|
plus
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/base.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/base.rb
|
Apache-2.0
|
def to_i
raise Sass::SyntaxError.new("#{inspect} is not an integer.")
end
|
@return [Integer] The integer value of this value
@raise [Sass::SyntaxError] if this value isn't an integer
|
to_i
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/base.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/base.rb
|
Apache-2.0
|
def to_h
raise Sass::SyntaxError.new("#{inspect} is not a map.")
end
|
Returns the value of this value as a hash. Most values don't have hash
representations, but [Map]s and empty [List]s do.
@return [Hash<Value, Value>] This value as a hash
@raise [Sass::SyntaxError] if this value doesn't have a hash representation
|
to_h
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/base.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/base.rb
|
Apache-2.0
|
def with_contents(contents, separator: self.separator, bracketed: self.bracketed)
Sass::Script::Value::List.new(contents, separator: separator, bracketed: bracketed)
end
|
Creates a new list containing `contents` but with the same brackets and
separators as this object, when interpreted as a list.
@param contents [Array<Value>] The contents of the new list.
@param separator [Symbol] The separator of the new list. Defaults to \{#separator}.
@param bracketed [Boolean] Whether the new list is bracketed. Defaults to \{#bracketed}.
@return [Sass::Script::Value::List]
|
with_contents
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/base.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/base.rb
|
Apache-2.0
|
def initialize(attrs, representation = nil, allow_both_rgb_and_hsl = false)
super(nil)
if attrs.is_a?(Array)
unless (3..4).include?(attrs.size)
raise ArgumentError.new("Color.new(array) expects a three- or four-element array")
end
red, green, blue = attrs[0...3].map {|c| Sass::Util.round(c)}
@attrs = {:red => red, :green => green, :blue => blue}
@attrs[:alpha] = attrs[3] ? attrs[3].to_f : 1
@representation = representation
else
attrs = attrs.reject {|_k, v| v.nil?}
hsl = [:hue, :saturation, :lightness] & attrs.keys
rgb = [:red, :green, :blue] & attrs.keys
if !allow_both_rgb_and_hsl && !hsl.empty? && !rgb.empty?
raise ArgumentError.new("Color.new(hash) may not have both HSL and RGB keys specified")
elsif hsl.empty? && rgb.empty?
raise ArgumentError.new("Color.new(hash) must have either HSL or RGB keys specified")
elsif !hsl.empty? && hsl.size != 3
raise ArgumentError.new("Color.new(hash) must have all three HSL values specified")
elsif !rgb.empty? && rgb.size != 3
raise ArgumentError.new("Color.new(hash) must have all three RGB values specified")
end
@attrs = attrs
@attrs[:hue] %= 360 if @attrs[:hue]
@attrs[:alpha] ||= 1
@representation = @attrs.delete(:representation)
end
[:red, :green, :blue].each do |k|
next if @attrs[k].nil?
@attrs[k] = Sass::Util.restrict(Sass::Util.round(@attrs[k]), 0..255)
end
[:saturation, :lightness].each do |k|
next if @attrs[k].nil?
@attrs[k] = Sass::Util.restrict(@attrs[k], 0..100)
end
@attrs[:alpha] = Sass::Util.restrict(@attrs[:alpha], 0..1)
end
|
Constructs an RGB or HSL color object,
optionally with an alpha channel.
RGB values are clipped within 0 and 255.
Saturation and lightness values are clipped within 0 and 100.
The alpha value is clipped within 0 and 1.
@raise [Sass::SyntaxError] if any color value isn't in the specified range
@overload initialize(attrs)
The attributes are specified as a hash. This hash must contain either
`:hue`, `:saturation`, and `:lightness` keys, or `:red`, `:green`, and
`:blue` keys. It cannot contain both HSL and RGB keys. It may also
optionally contain an `:alpha` key, and a `:representation` key
indicating the original representation of the color that the user wrote
in their stylesheet.
@param attrs [{Symbol => Numeric}] A hash of color attributes to values
@raise [ArgumentError] if not enough attributes are specified,
or both RGB and HSL attributes are specified
@overload initialize(rgba, [representation])
The attributes are specified as an array.
This overload only supports RGB or RGBA colors.
@param rgba [Array<Numeric>] A three- or four-element array
of the red, green, blue, and optionally alpha values (respectively)
of the color
@param representation [String] The original representation of the color
that the user wrote in their stylesheet.
@raise [ArgumentError] if not enough attributes are specified
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/color.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/color.rb
|
Apache-2.0
|
def red
hsl_to_rgb!
@attrs[:red]
end
|
The red component of the color.
@return [Integer]
|
red
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/color.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/color.rb
|
Apache-2.0
|
def green
hsl_to_rgb!
@attrs[:green]
end
|
The green component of the color.
@return [Integer]
|
green
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/color.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/color.rb
|
Apache-2.0
|
def blue
hsl_to_rgb!
@attrs[:blue]
end
|
The blue component of the color.
@return [Integer]
|
blue
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/color.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/script/value/color.rb
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.