Add UTILS.IsInstanceOf = function( object, className )

This function takes any object and check if it is an instance of className.
The object can be either a MOOSE class or a basic lua type.
This commit is contained in:
132nd-etcher
2017-07-12 14:55:15 +02:00
parent 2f416ea98e
commit 82fd08521f
2 changed files with 163 additions and 0 deletions

View File

@@ -236,12 +236,41 @@ which are excellent tools to be reused in an OO environment!.</p>
<td class="name" nowrap="nowrap"><a href="##(UTILS).FeetToMeters">UTILS.FeetToMeters(feet)</a></td>
<td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(UTILS).IsInstanceOf">UTILS.IsInstanceOf(object, className)</a></td>
<td class="summary">
<p>Function to infer instance of an object</p>
<h3>Examples:</h3>
<ul>
<li><p>UTILS.IsInstanceOf( 'some text', 'string' ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( some_function, 'function' ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( 10, 'number' ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( false, 'boolean' ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( nil, 'nil' ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( ZONE:New( 'some zone', ZONE ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( ZONE:New( 'some zone', 'ZONE' ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( ZONE:New( 'some zone', 'zone' ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( ZONE:New( 'some zone', 'BASE' ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( ZONE:New( 'some zone', 'GROUP' ) will return false</p></li>
</ul>
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(UTILS).KmphToMps">UTILS.KmphToMps(kmph)</a></td>
<td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(UTILS).KnotsToKmph">UTILS.KnotsToKmph(knots)</a></td>
<td class="summary">
</td>
</tr>
<tr>
@@ -608,6 +637,56 @@ use negative idp for rounding ahead of decimal place, positive for rounding afte
<dl class="function">
<dt>
<a id="#(UTILS).IsInstanceOf" >
<strong>UTILS.IsInstanceOf(object, className)</strong>
</a>
</dt>
<dd>
<p>Function to infer instance of an object</p>
<h3>Examples:</h3>
<ul>
<li><p>UTILS.IsInstanceOf( 'some text', 'string' ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( some_function, 'function' ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( 10, 'number' ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( false, 'boolean' ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( nil, 'nil' ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( ZONE:New( 'some zone', ZONE ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( ZONE:New( 'some zone', 'ZONE' ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( ZONE:New( 'some zone', 'zone' ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( ZONE:New( 'some zone', 'BASE' ) will return true</p></li>
<li><p>UTILS.IsInstanceOf( ZONE:New( 'some zone', 'GROUP' ) will return false</p></li>
</ul>
<h3>Parameters</h3>
<ul>
<li>
<p><code><em> object </em></code>:
is the object to be evaluated</p>
</li>
<li>
<p><code><em> className </em></code>:
is the name of the class to evaluate (can be either a string or a Moose class)</p>
</li>
</ul>
<h3>Return value</h3>
<p><em>#boolean:</em></p>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(UTILS).KmphToMps" >
<strong>UTILS.KmphToMps(kmph)</strong>
</a>
@@ -629,6 +708,27 @@ use negative idp for rounding ahead of decimal place, positive for rounding afte
<dl class="function">
<dt>
<a id="#(UTILS).KnotsToKmph" >
<strong>UTILS.KnotsToKmph(knots)</strong>
</a>
</dt>
<dd>
<h3>Parameter</h3>
<ul>
<li>
<p><code><em> knots </em></code>: </p>
</li>
</ul>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(UTILS).KnotsToMps" >
<strong>UTILS.KnotsToMps(knots)</strong>
</a>