sass-site/source/documentation/Sass/Script/Functions/EvaluationContext.html

1160 lines
55 KiB
HTML
Raw Normal View History

2018-10-22 23:13:05 +02:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
Class: Sass::Script::Functions::EvaluationContext
&mdash; Documentation by YARD 0.9.12
</title>
<link rel="stylesheet" href="../../../css/style.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="../../../../assets/css/docs.css" type="text/css" charset="utf-8" />
<script type="text/javascript" charset="utf-8">
hasFrames = window.top.frames.main ? true : false;
relpath = '../../../';
framesUrl = "../../../frames.html#!Sass/Script/Functions/EvaluationContext.html";
</script>
<script type="text/javascript" charset="utf-8" src="../../../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../js/app.js"></script>
</head>
<body>
<div id="header">
<div id="menu">
<a href="../../../_index.html">Index (E)</a> &raquo;
<span class='title'><span class='object_link'><a href="../../../Sass.html" title="Sass (module)">Sass</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../Script.html" title="Sass::Script (module)">Script</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Functions.html" title="Sass::Script::Functions (module)">Functions</a></span></span>
&raquo;
<span class="title">EvaluationContext</span>
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="../../../class_list.html">
Class List
</a>
<a class="full_list_link" id="method_list_link"
href="../../../method_list.html">
Method List
</a>
<a class="full_list_link" id="file_list_link"
href="../../../file_list.html">
File List
</a>
</div>
<div class="clear"></div>
</div>
<iframe id="search_frame"></iframe>
<div id="content"><h1>Class: Sass::Script::Functions::EvaluationContext
</h1>
<dl class="box">
<dt class="r1">Inherits:</dt>
<dd class="r1">
<span class="inheritName">Object</span>
<ul class="fullTree">
<li>Object</li>
<li class="next">Sass::Script::Functions::EvaluationContext</li>
</ul>
<a href="#" class="inheritanceTree">show all</a>
</dd>
<dt class="r2">Includes:</dt>
<dd class="r2"><span class='object_link'><a href="../Functions.html" title="Sass::Script::Functions (module)">Sass::Script::Functions</a></span>, <span class='object_link'><a href="../Value/Helpers.html" title="Sass::Script::Value::Helpers (module)">Value::Helpers</a></span></dd>
<dt class="r1 last">Defined in:</dt>
<dd class="r1 last">.ruby-sass/lib/sass/script/functions.rb</dd>
</dl>
<div class="clear"></div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>The context in which methods in <span class='object_link'><a href="../Functions.html" title="Sass::Script::Functions (module)">Sass::Script::Functions</a></span> are evaluated. That
means that all instance methods of <span class='object_link'><a href="" title="Sass::Script::Functions::EvaluationContext (class)">EvaluationContext</a></span> are available to use
in functions.</p>
</div>
</div>
<div class="tags">
</div>
<h2>Constant Summary</h2>
<dl class="constants">
<dt id="TYPE_NAMES-constant" class="">TYPE_NAMES =
<div class="docstring">
<div class="discussion">
<p>The human-readable names for [Sass::Script::Value::Base]. The default is
just the downcased name of the type.</p>
</div>
</div>
<div class="tags">
</div>
</dt>
<dd><pre class="code"><span class='lbrace'>{</span><span class='symbol'>:ArgList</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>variable argument list</span><span class='tstring_end'>&#39;</span></span><span class='rbrace'>}</span></pre></dd>
</dl>
<h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#environment-instance_method" title="#environment (instance method)">#<strong>environment</strong> &#x21d2; Environment </a>
</span>
<span class="note title readonly">readonly</span>
<span class="summary_desc"><div class='inline'>
<p>The environment for this function.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#options-instance_method" title="#options (instance method)">#<strong>options</strong> &#x21d2; {Symbol =&gt; Object} </a>
</span>
<span class="note title readonly">readonly</span>
<span class="summary_desc"><div class='inline'>
<p>The options hash for the <span class='object_link'><a href="../../Engine.html" title="Sass::Engine (class)">Engine</a></span> that is processing the function
call.</p>
</div></span>
</li>
</ul>
<h2>
Instance Method Summary
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#assert_integer-instance_method" title="#assert_integer (instance method)">#<strong>assert_integer</strong>(number, name = nil) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Asserts that the value is an integer.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#assert_type-instance_method" title="#assert_type (instance method)">#<strong>assert_type</strong>(value, type, name = nil) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Asserts that the type of a given SassScript value is the expected type
(designated by a symbol).</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#assert_unit-instance_method" title="#assert_unit (instance method)">#<strong>assert_unit</strong>(number, unit, name = nil) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Asserts that the unit of the number is as expected.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(environment) &#x21d2; EvaluationContext </a>
</span>
<span class="note title constructor">constructor</span>
<span class="summary_desc"><div class='inline'>
<p>A new instance of EvaluationContext.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#perform-instance_method" title="#perform (instance method)">#<strong>perform</strong>(node, env = environment.caller) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Performs a node that has been delayed for execution.</p>
</div></span>
</li>
</ul>
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Value/Helpers.html" title="Sass::Script::Value::Helpers (module)">Value::Helpers</a></span></h3>
<p class="inherited"><span class='object_link'><a href="../Value/Helpers.html#bool-instance_method" title="Sass::Script::Value::Helpers#bool (method)">#bool</a></span>, <span class='object_link'><a href="../Value/Helpers.html#calc%3F-instance_method" title="Sass::Script::Value::Helpers#calc? (method)">#calc?</a></span>, <span class='object_link'><a href="../Value/Helpers.html#hex_color-instance_method" title="Sass::Script::Value::Helpers#hex_color (method)">#hex_color</a></span>, <span class='object_link'><a href="../Value/Helpers.html#hsl_color-instance_method" title="Sass::Script::Value::Helpers#hsl_color (method)">#hsl_color</a></span>, <span class='object_link'><a href="../Value/Helpers.html#list-instance_method" title="Sass::Script::Value::Helpers#list (method)">#list</a></span>, <span class='object_link'><a href="../Value/Helpers.html#map-instance_method" title="Sass::Script::Value::Helpers#map (method)">#map</a></span>, <span class='object_link'><a href="../Value/Helpers.html#null-instance_method" title="Sass::Script::Value::Helpers#null (method)">#null</a></span>, <span class='object_link'><a href="../Value/Helpers.html#number-instance_method" title="Sass::Script::Value::Helpers#number (method)">#number</a></span>, <span class='object_link'><a href="../Value/Helpers.html#parse_complex_selector-instance_method" title="Sass::Script::Value::Helpers#parse_complex_selector (method)">#parse_complex_selector</a></span>, <span class='object_link'><a href="../Value/Helpers.html#parse_compound_selector-instance_method" title="Sass::Script::Value::Helpers#parse_compound_selector (method)">#parse_compound_selector</a></span>, <span class='object_link'><a href="../Value/Helpers.html#parse_selector-instance_method" title="Sass::Script::Value::Helpers#parse_selector (method)">#parse_selector</a></span>, <span class='object_link'><a href="../Value/Helpers.html#quoted_string-instance_method" title="Sass::Script::Value::Helpers#quoted_string (method)">#quoted_string</a></span>, <span class='object_link'><a href="../Value/Helpers.html#rgb_color-instance_method" title="Sass::Script::Value::Helpers#rgb_color (method)">#rgb_color</a></span>, <span class='object_link'><a href="../Value/Helpers.html#special_number%3F-instance_method" title="Sass::Script::Value::Helpers#special_number? (method)">#special_number?</a></span>, <span class='object_link'><a href="../Value/Helpers.html#unquoted_string-instance_method" title="Sass::Script::Value::Helpers#unquoted_string (method)">#unquoted_string</a></span>, <span class='object_link'><a href="../Value/Helpers.html#var%3F-instance_method" title="Sass::Script::Value::Helpers#var? (method)">#var?</a></span></p>
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Functions.html" title="Sass::Script::Functions (module)">Sass::Script::Functions</a></span></h3>
<p class="inherited"><span class='object_link'><a href="../Functions.html#abs-instance_method" title="Sass::Script::Functions#abs (method)">#abs</a></span>, <span class='object_link'><a href="../Functions.html#adjust_color-instance_method" title="Sass::Script::Functions#adjust_color (method)">#adjust_color</a></span>, <span class='object_link'><a href="../Functions.html#adjust_hue-instance_method" title="Sass::Script::Functions#adjust_hue (method)">#adjust_hue</a></span>, <span class='object_link'><a href="../Functions.html#alpha-instance_method" title="Sass::Script::Functions#alpha (method)">#alpha</a></span>, <span class='object_link'><a href="../Functions.html#append-instance_method" title="Sass::Script::Functions#append (method)">#append</a></span>, <span class='object_link'><a href="../Functions.html#blue-instance_method" title="Sass::Script::Functions#blue (method)">#blue</a></span>, <span class='object_link'><a href="../Functions.html#call-instance_method" title="Sass::Script::Functions#call (method)">#call</a></span>, <span class='object_link'><a href="../Functions.html#ceil-instance_method" title="Sass::Script::Functions#ceil (method)">#ceil</a></span>, <span class='object_link'><a href="../Functions.html#change_color-instance_method" title="Sass::Script::Functions#change_color (method)">#change_color</a></span>, <span class='object_link'><a href="../Functions.html#comparable-instance_method" title="Sass::Script::Functions#comparable (method)">#comparable</a></span>, <span class='object_link'><a href="../Functions.html#complement-instance_method" title="Sass::Script::Functions#complement (method)">#complement</a></span>, <span class='object_link'><a href="../Functions.html#content_exists-instance_method" title="Sass::Script::Functions#content_exists (method)">#content_exists</a></span>, <span class='object_link'><a href="../Functions.html#counter-instance_method" title="Sass::Script::Functions#counter (method)">#counter</a></span>, <span class='object_link'><a href="../Functions.html#counters-instance_method" title="Sass::Script::Functions#counters (method)">#counters</a></span>, <span class='object_link'><a href="../Functions.html#darken-instance_method" title="Sass::Script::Functions#darken (method)">#darken</a></span>, <span class='object_link'><a href="../Functions.html#declare-class_method" title="Sass::Script::Functions.declare (method)">declare</a></span>, <span class='object_link'><a href="../Functions.html#desaturate-instance_method" title="Sass::Script::Functions#desaturate (method)">#desaturate</a></span>, <span class='object_link'><a href="../Functions.html#feature_exists-instance_method" title="Sass::Script::Functions#feature_exists (method)">#feature_exists</a></span>, <span class='object_link'><a href="../Functions.html#floor-instance_method" title="Sass::Script::Functions#floor (method)">#floor</a></span>, <span class='object_link'><a href="../Functions.html#function_exists-instance_method" title="Sass::Script::Functions#function_exists (method)">#function_exists</a></span>, <span class='object_link'><a href="../Functions.html#get_function-instance_method" title="Sass::Script::Functions#get_function (method)">#get_function</a></span>, <span class='object_link'><a href="../Functions.html#global_variable_exists-instance_method" title="Sass::Script::Functions#global_variable_exists (method)">#global_variable_exists</a></span>, <span class='object_link'><a href="../Functions.html#grayscale-instance_method" title="Sass::Script::Functions#grayscale (method)">#grayscale</a></span>, <span class='object_link'><a href="../Functions.html#green-instance_method" title="Sass::Script::Functions#green (method)">#green</a></span>, <span class='object_link'><a href="../Functions.html#hsl-instance_method" title="Sass::Script::Functions#hsl (method)">#hsl</a></span>, <span class='object_link'><a href="../Functions.html#hsla-instance_method" title="Sass::Script::Functions#hsla (method)">#hsla</a></span>, <span class='object_link'><a href="../Functions.html#hue-instance_method" title="Sass::Script::Functions#hue (m
<div id="constructor_details" class="method_details_list">
<h2>Constructor Details</h2>
<div class="method_details first">
<h3 class="signature first" id="initialize-instance_method">
#<strong>initialize</strong>(environment) &#x21d2; <tt><span class='object_link'><a href="" title="Sass::Script::Functions::EvaluationContext (class)">EvaluationContext</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns a new instance of EvaluationContext</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>environment</span>
<span class='type'>(<tt><span class='object_link'><a href="../../Environment.html" title="Sass::Environment (class)">Environment</a></span></tt>)</span>
&mdash;
<div class='inline'>
<p>See <span class='object_link'><a href="#environment-instance_method" title="Sass::Script::Functions::EvaluationContext#environment (method)">#environment</a></span></p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
519
520
521
522</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/script/functions.rb', line 519</span>
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_environment'>environment</span><span class='rparen'>)</span>
<span class='ivar'>@environment</span> <span class='op'>=</span> <span class='id identifier rubyid_environment'>environment</span>
<span class='ivar'>@options</span> <span class='op'>=</span> <span class='id identifier rubyid_environment'>environment</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="constructor_details" class="method_details_list">
<h2>Constructor Details</h2>
<div class="method_details first">
<h3 class="signature first" id="initialize-instance_method">
#<strong>initialize</strong>(environment) &#x21d2; <tt><span class='object_link'><a href="" title="Sass::Script::Functions::EvaluationContext (class)">EvaluationContext</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns a new instance of EvaluationContext</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>environment</span>
<span class='type'>(<tt><span class='object_link'><a href="../../Environment.html" title="Sass::Environment (class)">Environment</a></span></tt>)</span>
&mdash;
<div class='inline'>
<p>See <span class='object_link'><a href="#environment-instance_method" title="Sass::Script::Functions::EvaluationContext#environment (method)">#environment</a></span></p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
519
520
521
522</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/script/functions.rb', line 519</span>
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_environment'>environment</span><span class='rparen'>)</span>
<span class='ivar'>@environment</span> <span class='op'>=</span> <span class='id identifier rubyid_environment'>environment</span>
<span class='ivar'>@options</span> <span class='op'>=</span> <span class='id identifier rubyid_environment'>environment</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="instance_attr_details" class="attr_details">
<h2>Instance Attribute Details</h2>
<span id=""></span>
<div class="method_details first">
<h3 class="signature first" id="environment-instance_method">
#<strong>environment</strong> &#x21d2; <tt><span class='object_link'><a href="../../Environment.html" title="Sass::Environment (class)">Environment</a></span></tt> <span class="extras">(readonly)</span>
</h3><div class="docstring">
<div class="discussion">
<p>The environment for this function. This environment&#39;s
<span class='object_link'><a href="../../Environment.html#parent-instance_method" title="Sass::Environment#parent (method)">Environment#parent</a></span> is the global environment, and its
Environment#caller is a read-only view of the local environment of the
caller of this function.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="../../Environment.html" title="Sass::Environment (class)">Environment</a></span></tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
511
512
513</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/script/functions.rb', line 511</span>
<span class='kw'>def</span> <span class='id identifier rubyid_environment'>environment</span>
<span class='ivar'>@environment</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<span id=""></span>
<div class="method_details ">
<h3 class="signature " id="options-instance_method">
#<strong>options</strong> &#x21d2; <tt>{Symbol =&gt; Object}</tt> <span class="extras">(readonly)</span>
</h3><div class="docstring">
<div class="discussion">
<p>The options hash for the <span class='object_link'><a href="../../Engine.html" title="Sass::Engine (class)">Engine</a></span> that is processing the function
call</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>{Symbol =&gt; Object}</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
516
517
518</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/script/functions.rb', line 516</span>
<span class='kw'>def</span> <span class='id identifier rubyid_options'>options</span>
<span class='ivar'>@options</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="assert_integer-instance_method">
#<strong>assert_integer</strong>(number, name = nil) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Asserts that the value is an integer.</p>
</div>
</div>
<div class="tags">
<div class="examples">
<p class="tag_title">Examples:</p>
<pre class="example code"><code>assert_integer 2px
assert_integer 2.5px
=&gt; SyntaxError: &quot;Expected 2.5px to be an integer&quot;
assert_integer 2.5px, &quot;width&quot;
=&gt; SyntaxError: &quot;Expected width to be an integer but got 2.5px&quot;</code></pre>
</div>
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>number</span>
<span class='type'>(<tt><span class='object_link'><a href="../Value/Base.html" title="Sass::Script::Value::Base (class)">Sass::Script::Value::Base</a></span></tt>)</span>
&mdash;
<div class='inline'>
<p>The value to be validated.</p>
</div>
</li>
<li>
<span class='name'>name</span>
<span class='type'>(<tt>::String</tt>)</span>
<em class="default">(defaults to: <tt>nil</tt>)</em>
&mdash;
<div class='inline'>
<p>The name of the parameter being validated.</p>
</div>
</li>
</ul>
<p class="tag_title">Raises:</p>
<ul class="raise">
<li>
<span class='type'>(<tt>ArgumentError</tt>)</span>
&mdash;
<div class='inline'>
<p>if number is not an integer or is not a number.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
593
594
595
596
597
598
599
600
601</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/script/functions.rb', line 593</span>
<span class='kw'>def</span> <span class='id identifier rubyid_assert_integer'>assert_integer</span><span class='lparen'>(</span><span class='id identifier rubyid_number'>number</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='id identifier rubyid_assert_type'>assert_type</span> <span class='id identifier rubyid_number'>number</span><span class='comma'>,</span> <span class='symbol'>:Number</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span>
<span class='kw'>return</span> <span class='kw'>if</span> <span class='id identifier rubyid_number'>number</span><span class='period'>.</span><span class='id identifier rubyid_int?'>int?</span>
<span class='kw'>if</span> <span class='id identifier rubyid_name'>name</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Expected $</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'> to be an integer but got </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_number'>number</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Expected </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_number'>number</span><span class='embexpr_end'>}</span><span class='tstring_content'> to be an integer</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="assert_type-instance_method">
#<strong>assert_type</strong>(value, type, name = nil) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Asserts that the type of a given SassScript value is the expected type
(designated by a symbol).</p>
<p>Valid types are `:Bool`, `:Color`, `:Number`, and `:String`. Note that
`:String` will match both double-quoted strings and unquoted identifiers.</p>
</div>
</div>
<div class="tags">
<div class="examples">
<p class="tag_title">Examples:</p>
<pre class="example code"><code><span class='id identifier rubyid_assert_type'>assert_type</span> <span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='symbol'>:String</span>
<span class='id identifier rubyid_assert_type'>assert_type</span> <span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='symbol'>:Number</span></code></pre>
</div>
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>value</span>
<span class='type'>(<tt><span class='object_link'><a href="../Value/Base.html" title="Sass::Script::Value::Base (class)">Sass::Script::Value::Base</a></span></tt>)</span>
&mdash;
<div class='inline'>
<p>A SassScript value</p>
</div>
</li>
<li>
<span class='name'>type</span>
<span class='type'>(<tt>Symbol</tt>, <tt>Array&lt;Symbol&gt;</tt>)</span>
&mdash;
<div class='inline'>
<p>The name(s) of the type the value is expected to be</p>
</div>
</li>
<li>
<span class='name'>name</span>
<span class='type'>(<tt>String</tt>, <tt>Symbol</tt>, <tt>nil</tt>)</span>
<em class="default">(defaults to: <tt>nil</tt>)</em>
&mdash;
<div class='inline'>
<p>The name of the argument.</p>
</div>
</li>
</ul>
<p class="tag_title">Raises:</p>
<ul class="raise">
<li>
<span class='type'>(<tt>ArgumentError</tt>)</span>
&mdash;
<div class='inline'>
<p>if value is not of the correct type.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/script/functions.rb', line 538</span>
<span class='kw'>def</span> <span class='id identifier rubyid_assert_type'>assert_type</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='id identifier rubyid_valid_types'>valid_types</span> <span class='op'>=</span> <span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='rparen'>)</span>
<span class='id identifier rubyid_found_type'>found_type</span> <span class='op'>=</span> <span class='id identifier rubyid_valid_types'>valid_types</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_t'>t</span><span class='op'>|</span>
<span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../../../Sass.html" title="Sass (module)">Sass</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Script.html" title="Sass::Script (module)">Script</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Value.html" title="Sass::Script::Value (module)">Value</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_t'>t</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='op'>||</span>
<span class='id identifier rubyid_t'>t</span> <span class='op'>==</span> <span class='symbol'>:Map</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../../../Sass.html" title="Sass (module)">Sass</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Script.html" title="Sass::Script (module)">Script</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Value.html" title="Sass::Script::Value (module)">Value</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Value/List.html" title="Sass::Script::Value::List (class)">List</a></span></span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
<span class='kw'>end</span>
<span class='kw'>if</span> <span class='id identifier rubyid_found_type'>found_type</span>
<span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_check_deprecated_interp'>check_deprecated_interp</span> <span class='kw'>if</span> <span class='id identifier rubyid_found_type'>found_type</span> <span class='op'>==</span> <span class='symbol'>:String</span>
<span class='kw'>return</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_err'>err</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_valid_types'>valid_types</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>==</span> <span class='int'>1</span>
<span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'> is not a </span><span class='embexpr_beg'>#{</span><span class='const'><span class='object_link'><a href="#TYPE_NAMES-constant" title="Sass::Script::Functions::EvaluationContext::TYPE_NAMES (constant)">TYPE_NAMES</a></span></span><span class='lbracket'>[</span><span class='id identifier rubyid_type'>type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='id identifier rubyid_type'>type</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>else</span>
<span class='id identifier rubyid_type_names'>type_names</span> <span class='op'>=</span> <span class='id identifier rubyid_valid_types'>valid_types</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_t'>t</span><span class='op'>|</span> <span class='const'><span class='object_link'><a href="#TYPE_NAMES-constant" title="Sass::Script::Functions::EvaluationContext::TYPE_NAMES (constant)">TYPE_NAMES</a></span></span><span class='lbracket'>[</span><span class='id identifier rubyid_t'>t</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='id identifier rubyid_t'>t</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span><span class='rbrace'>}</span>
<span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'> is not any of </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_type_names'>type_names</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>, </span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span>
<span class='id identifier rubyid_err'>err</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>$</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_tr'>tr</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>_</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>-</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>: </span><span class='tstring_end'>&quot;</span></span> <span class='op'>+</span> <span class='id identifier rubyid_err'>err</span> <span class='kw'>if</span> <span class='id identifier rubyid_name'>name</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_err'>err</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="assert_unit-instance_method">
#<strong>assert_unit</strong>(number, unit, name = nil) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Asserts that the unit of the number is as expected.</p>
</div>
</div>
<div class="tags">
<div class="examples">
<p class="tag_title">Examples:</p>
<pre class="example code"><code><span class='id identifier rubyid_assert_unit'>assert_unit</span> <span class='id identifier rubyid_number'>number</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>px</span><span class='tstring_end'>&quot;</span></span>
<span class='id identifier rubyid_assert_unit'>assert_unit</span> <span class='id identifier rubyid_number'>number</span><span class='comma'>,</span> <span class='kw'>nil</span></code></pre>
</div>
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>number</span>
<span class='type'>(<tt><span class='object_link'><a href="../Value/Number.html" title="Sass::Script::Value::Number (class)">Sass::Script::Value::Number</a></span></tt>)</span>
&mdash;
<div class='inline'>
<p>The number to be validated.</p>
</div>
</li>
<li>
<span class='name'>unit</span>
<span class='type'>(<tt>::String</tt>)</span>
&mdash;
<div class='inline'>
<p>The unit that the number must have. If nil, the number must be unitless.</p>
</div>
</li>
<li>
<span class='name'>name</span>
<span class='type'>(<tt>::String</tt>)</span>
<em class="default">(defaults to: <tt>nil</tt>)</em>
&mdash;
<div class='inline'>
<p>The name of the parameter being validated.</p>
</div>
</li>
</ul>
<p class="tag_title">Raises:</p>
<ul class="raise">
<li>
<span class='type'>(<tt>ArgumentError</tt>)</span>
&mdash;
<div class='inline'>
<p>if number is not of the correct unit or is not a number.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
571
572
573
574
575
576
577
578
579
580</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/script/functions.rb', line 571</span>
<span class='kw'>def</span> <span class='id identifier rubyid_assert_unit'>assert_unit</span><span class='lparen'>(</span><span class='id identifier rubyid_number'>number</span><span class='comma'>,</span> <span class='id identifier rubyid_unit'>unit</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='id identifier rubyid_assert_type'>assert_type</span> <span class='id identifier rubyid_number'>number</span><span class='comma'>,</span> <span class='symbol'>:Number</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span>
<span class='kw'>return</span> <span class='kw'>if</span> <span class='id identifier rubyid_number'>number</span><span class='period'>.</span><span class='id identifier rubyid_is_unit?'>is_unit?</span><span class='lparen'>(</span><span class='id identifier rubyid_unit'>unit</span><span class='rparen'>)</span>
<span class='id identifier rubyid_expectation'>expectation</span> <span class='op'>=</span> <span class='id identifier rubyid_unit'>unit</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>have a unit of </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_unit'>unit</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>be unitless</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>if</span> <span class='id identifier rubyid_name'>name</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Expected $</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'> to </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_expectation'>expectation</span><span class='embexpr_end'>}</span><span class='tstring_content'> but got </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_number'>number</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Expected </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_number'>number</span><span class='embexpr_end'>}</span><span class='tstring_content'> to </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_expectation'>expectation</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="perform-instance_method">
#<strong>perform</strong>(node, env = environment.caller) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Performs a node that has been delayed for execution.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>node</span>
<span class='type'>(<tt><span class='object_link'><a href="../Tree/Node.html" title="Sass::Script::Tree::Node (class)">Sass::Script::Tree::Node</a></span></tt>, <tt><span class='object_link'><a href="../Value/Base.html" title="Sass::Script::Value::Base (class)">Sass::Script::Value::Base</a></span></tt>)</span>
&mdash;
<div class='inline'>
<p>When this is a tree node, it&#39;s performed in the caller&#39;s
environment. When it&#39;s a value (which can happen when the value had to
be performed already like for a splat), it&#39;s returned as-is.</p>
</div>
</li>
<li>
<span class='name'>env</span>
<span class='type'>(<tt><span class='object_link'><a href="../../Environment.html" title="Sass::Environment (class)">Sass::Environment</a></span></tt>)</span>
<em class="default">(defaults to: <tt>environment.caller</tt>)</em>
&mdash;
<div class='inline'>
<p>The environment within which to perform the node. Defaults to the
(read-only) environment of the caller.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
613
614
615
616
617
618
619</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/script/functions.rb', line 613</span>
<span class='kw'>def</span> <span class='id identifier rubyid_perform'>perform</span><span class='lparen'>(</span><span class='id identifier rubyid_node'>node</span><span class='comma'>,</span> <span class='id identifier rubyid_env'>env</span> <span class='op'>=</span> <span class='id identifier rubyid_environment'>environment</span><span class='period'>.</span><span class='id identifier rubyid_caller'>caller</span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='id identifier rubyid_node'>node</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../../../Sass.html" title="Sass (module)">Sass</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Script.html" title="Sass::Script (module)">Script</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Value.html" title="Sass::Script::Value (module)">Value</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Value/Base.html" title="Sass::Script::Value::Base (class)">Base</a></span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_node'>node</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_node'>node</span><span class='period'>.</span><span class='id identifier rubyid_perform'>perform</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Mon Oct 22 13:20:52 2018 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.12 (ruby-2.5.3).
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-535380-14', 'sass-lang.com');
ga('send', 'pageview');
</script>
</body>
</html>