docs/Lazier/Object.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Module: Lazier::Object
— Documentation by YARD 0.9.5
</title>
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
<script type="text/javascript" charset="utf-8">
pathId = "Lazier::Object";
relpath = '../';
</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 class="nav_wrap">
<iframe id="nav" src="../class_list.html"></iframe>
<div id="resizer"></div>
</div>
<div id="main" tabindex="-1">
<div id="header">
<div id="menu">
<a href="../_index.html">Index (O)</a> »
<span class='title'><span class='object_link'><a href="../Lazier.html" title="Lazier (module)">Lazier</a></span></span>
»
<span class="title">Object</span>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="../class_list.html">
<svg width="24" height="24">
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
</svg>
</a>
</div>
<div class="clear"></div>
</div>
<iframe id="search_frame" src="../class_list.html"></iframe>
<div id="content"><h1>Module: Lazier::Object
</h1>
<div class="box_info">
<dl>
<dt>Extended by:</dt>
<dd>ActiveSupport::Concern</dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/lazier/object.rb</dd>
</dl>
</div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>Extensions for all objects.</p>
</div>
</div>
<div class="tags">
</div>
<h2>Constant Summary</h2>
<dl class="constants">
<dt id="BOOLEAN_MATCHER-constant" class="">BOOLEAN_MATCHER =
<div class="docstring">
<div class="discussion">
<p>Expression to match a boolean value.</p>
</div>
</div>
<div class="tags">
</div>
</dt>
<dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^(\s*(1|0|true|false|yes|no|t|f|y|n)\s*)$</span><span class='regexp_end'>/i</span></span></pre></dd>
<dt id="BOOLEAN_TRUE_MATCHER-constant" class="">BOOLEAN_TRUE_MATCHER =
<div class="docstring">
<div class="discussion">
<p>Expression to match a true value.</p>
</div>
</div>
<div class="tags">
</div>
</dt>
<dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^(\s*(1|true|yes|t|y)\s*)$</span><span class='regexp_end'>/i</span></span></pre></dd>
<dt id="INTEGER_MATCHER-constant" class="">INTEGER_MATCHER =
<div class="docstring">
<div class="discussion">
<p>Expression to match a integer value.</p>
</div>
</div>
<div class="tags">
</div>
</dt>
<dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^([+-]?)(\d+)$</span><span class='regexp_end'>/</span></span></pre></dd>
<dt id="FLOAT_MATCHER-constant" class="">FLOAT_MATCHER =
<div class="docstring">
<div class="discussion">
<p>Expression to match a float value.</p>
</div>
</div>
<div class="tags">
</div>
</dt>
<dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^([+-]?)(\d+)([.,]\d+)?$</span><span class='regexp_end'>/</span></span></pre></dd>
</dl>
<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="#boolean%3F-instance_method" title="#boolean? (instance method)">#<strong>boolean?</strong> ⇒ Boolean </a>
</span>
<span class="summary_desc"><div class='inline'><p>Checks if the object is a valid boolean value.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#ensure-instance_method" title="#ensure (instance method)">#<strong>ensure</strong>(default, verifier = :blank?) ⇒ String </a>
</span>
<span class="summary_desc"><div class='inline'><p>Makes sure that the object is set to something meaningful.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#ensure_array-instance_method" title="#ensure_array (instance method)">#<strong>ensure_array</strong>(default: nil, no_duplicates: false, compact: false, flatten: false, sanitizer: nil, &block) ⇒ Array </a>
</span>
<span class="summary_desc"><div class='inline'><p>Makes sure that the object is an array.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#ensure_hash-instance_method" title="#ensure_hash (instance method)">#<strong>ensure_hash</strong>(accesses: nil, default: {}, sanitizer: nil, &block) ⇒ Hash </a>
</span>
<span class="summary_desc"><div class='inline'><p>Makes sure that the object is an hash.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#ensure_string-instance_method" title="#ensure_string (instance method)">#<strong>ensure_string</strong>(default = "", conversion_method = :to_s) ⇒ String </a>
</span>
<span class="summary_desc"><div class='inline'><p>Makes sure that the object is a string.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#float%3F-instance_method" title="#float? (instance method)">#<strong>float?</strong> ⇒ Boolean </a>
</span>
<span class="summary_desc"><div class='inline'><p>Checks if the object is a valid float.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#format_boolean-instance_method" title="#format_boolean (instance method)">#<strong>format_boolean</strong>(true_name: nil, false_name: nil) ⇒ String </a>
</span>
<span class="summary_desc"><div class='inline'><p>Formats a boolean.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#format_number-instance_method" title="#format_number (instance method)">#<strong>format_number</strong>(precision: nil, decimal_separator: nil, add_string: nil, k_separator: nil) ⇒ String|NilClass </a>
</span>
<span class="summary_desc"><div class='inline'><p>Formats a number.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#indexize-instance_method" title="#indexize (instance method)">#<strong>indexize</strong>(length: 2, filler: "0", formatter: :rjust) ⇒ String </a>
</span>
<span class="summary_desc"><div class='inline'><p>Prepares an object to be printed in list summaries, like.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#integer%3F-instance_method" title="#integer? (instance method)">#<strong>integer?</strong> ⇒ Boolean </a>
</span>
<span class="summary_desc"><div class='inline'><p>Checks if the object is a valid integer.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#normalize_number-instance_method" title="#normalize_number (instance method)">#<strong>normalize_number</strong> ⇒ String </a>
</span>
<span class="summary_desc"><div class='inline'><p>Normalizes a number for conversion.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#number%3F-instance_method" title="#number? (instance method)">#<strong>number?</strong>(klass = Integer, matcher = ::Lazier::Object::FLOAT_MATCHER) ⇒ Boolean </a>
</span>
<span class="summary_desc"><div class='inline'><p>Checks if the object is of a numeric class of matches a numeric string expression.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#round_to_precision-instance_method" title="#round_to_precision (instance method)">#<strong>round_to_precision</strong>(precision = 2) ⇒ Float </a>
</span>
<span class="summary_desc"><div class='inline'><p>Returns the rounded float representaton of the object.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#safe_send-instance_method" title="#safe_send (instance method)">#<strong>safe_send</strong>(method, *args, &block) ⇒ Object|nil </a>
</span>
<span class="summary_desc"><div class='inline'><p>Sends a method to the object.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#to_boolean-instance_method" title="#to_boolean (instance method)">#<strong>to_boolean</strong> ⇒ Boolean </a>
</span>
<span class="summary_desc"><div class='inline'><p>Converts the object to a boolean.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#to_debug-instance_method" title="#to_debug (instance method)">#<strong>to_debug</strong>(format: :pretty_json, as_exception: true) ⇒ String </a>
</span>
<span class="summary_desc"><div class='inline'><p>Inspects an object.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#to_float-instance_method" title="#to_float (instance method)">#<strong>to_float</strong>(default = 0.0) ⇒ Float </a>
</span>
<span class="summary_desc"><div class='inline'><p>Converts the object to a float.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#to_integer-instance_method" title="#to_integer (instance method)">#<strong>to_integer</strong>(default = 0) ⇒ Fixnum </a>
</span>
<span class="summary_desc"><div class='inline'><p>Converts the object to a integer.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#to_pretty_json-instance_method" title="#to_pretty_json (instance method)">#<strong>to_pretty_json</strong> ⇒ String </a>
</span>
<span class="summary_desc"><div class='inline'><p>Converts an object to a pretty formatted JSON string.</p>
</div></span>
</li>
</ul>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="boolean?-instance_method">
#<strong>boolean?</strong> ⇒ <tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Checks if the object is a valid boolean value.</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="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
—
<div class='inline'><p><code>true</code> is a valid boolean value, <code>false</code> otherwise.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
54
55
56</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 54</span>
<span class='kw'>def</span> <span class='id identifier rubyid_boolean?'>boolean?</span>
<span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>TrueClass</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>FalseClass</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_to_s'>to_s</span> <span class='op'>=~</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>Object</span><span class='op'>::</span><span class='const'>BOOLEAN_MATCHER</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="ensure-instance_method">
#<strong>ensure</strong>(default, verifier = :blank?) ⇒ <tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Makes sure that the object is set to something meaningful.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>default</span>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
—
<div class='inline'><p>The default value to return if the <code>verifier</code> or the block returns true.</p>
</div>
</li>
<li>
<span class='name'>verifier</span>
<span class='type'>(<tt>Symbol</tt>)</span>
<em class="default">(defaults to: <tt>:blank?</tt>)</em>
—
<div class='inline'><p>The method used to verify if the object is NOT meaningful. <em>Ignored if a block is passed.</em></p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
—
<div class='inline'><p>The current object or the <code>default_value</code>.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
75
76
77
78</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 75</span>
<span class='kw'>def</span> <span class='kw'>ensure</span><span class='lparen'>(</span><span class='id identifier rubyid_default'>default</span><span class='comma'>,</span> <span class='id identifier rubyid_verifier'>verifier</span> <span class='op'>=</span> <span class='symbol'>:blank?</span><span class='rparen'>)</span>
<span class='id identifier rubyid_valid'>valid</span> <span class='op'>=</span> <span class='id identifier rubyid_block_given?'>block_given?</span> <span class='op'>?</span> <span class='kw'>yield</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_verifier'>verifier</span><span class='rparen'>)</span>
<span class='op'>!</span><span class='id identifier rubyid_valid'>valid</span> <span class='op'>?</span> <span class='kw'>self</span> <span class='op'>:</span> <span class='id identifier rubyid_default'>default</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="ensure_array-instance_method">
#<strong>ensure_array</strong>(default: nil, no_duplicates: false, compact: false, flatten: false, sanitizer: nil, &block) ⇒ <tt>Array</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Makes sure that the object is an array. For non array objects, return a single element array containing the object.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>default</span>
<span class='type'>(<tt>Array|NilClass</tt>)</span>
—
<div class='inline'><p>The default array to use. If not specified, an array containing the object is returned.</p>
</div>
</li>
<li>
<span class='name'>no_duplicates</span>
<span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
—
<div class='inline'><p>Whether to remove duplicates from the array before sanitizing.</p>
</div>
</li>
<li>
<span class='name'>compact</span>
<span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
—
<div class='inline'><p>Whether to compact the array before sanitizing.</p>
</div>
</li>
<li>
<span class='name'>flatten</span>
<span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
—
<div class='inline'><p>Whether to flatten the array before sanitizing.</p>
</div>
</li>
<li>
<span class='name'>sanitizer</span>
<span class='type'>(<tt>Symbol|NilClass</tt>)</span>
—
<div class='inline'><p>If not <code>nil</code>, the method to use to sanitize entries of the array. <em>Ignored if a block is present.</em></p>
</div>
</li>
<li>
<span class='name'>block</span>
<span class='type'>(<tt>Proc</tt>)</span>
—
<div class='inline'><p>A block to sanitize entries. It must accept the value as unique argument.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Array</tt>)</span>
—
<div class='inline'><p>If the object is an array, then the object itself, a single element array containing the object otherwise.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
102
103
104
105
106
107
108
109
110
111
112</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 102</span>
<span class='kw'>def</span> <span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>no_duplicates:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>sanitizer:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span>
<span class='kw'>if</span> <span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
<span class='kw'>self</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_default'>default</span> <span class='op'>||</span> <span class='lbracket'>[</span><span class='kw'>self</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_manipulate_array'>manipulate_array</span><span class='lparen'>(</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_no_duplicates'>no_duplicates</span><span class='comma'>,</span> <span class='id identifier rubyid_compact'>compact</span><span class='comma'>,</span> <span class='id identifier rubyid_flatten'>flatten</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='lparen'>(</span><span class='id identifier rubyid_block'>block</span> <span class='op'>||</span> <span class='id identifier rubyid_sanitizer'>sanitizer</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span> <span class='op'>||</span> <span class='id identifier rubyid_sanitizer'>sanitizer</span>
<span class='id identifier rubyid_manipulate_array'>manipulate_array</span><span class='lparen'>(</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_no_duplicates'>no_duplicates</span><span class='comma'>,</span> <span class='id identifier rubyid_compact'>compact</span><span class='comma'>,</span> <span class='id identifier rubyid_flatten'>flatten</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="ensure_hash-instance_method">
#<strong>ensure_hash</strong>(accesses: nil, default: {}, sanitizer: nil, &block) ⇒ <tt><span class='object_link'><a href="Hash.html" title="Lazier::Hash (module)">Hash</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Makes sure that the object is an hash. For non hash objects, return an hash basing on the <code>default_value</code> parameter.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>accesses</span>
<span class='type'>(<tt>Symbol|NilClass|Array</tt>)</span>
—
<div class='inline'><p>The requested access for the keys of the returned object.</p>
</div>
</li>
<li>
<span class='name'>default</span>
<span class='type'>(<tt><span class='object_link'><a href="Hash.html" title="Lazier::Hash (module)">Hash</a></span>|<span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span>|Symbol|NilClass</tt>)</span>
—
<div class='inline'><p>The default value to use. If it is an <code>Hash</code>, it is returned as value otherwise it is used to build
as a key to build an hash with the current object as only value (everything but strings and symbols are mapped to <code>key</code>).
Passing <code>nil</code> is equal to pass an empty Hash.</p>
</div>
</li>
<li>
<span class='name'>sanitizer</span>
<span class='type'>(<tt>Symbol|NilClass</tt>)</span>
—
<div class='inline'><p>If not <code>nil</code>, the method to use to sanitize values of the hash. <em>Ignored if <code>block</code> is present.</em></p>
</div>
</li>
<li>
<span class='name'>block</span>
<span class='type'>(<tt>Proc</tt>)</span>
—
<div class='inline'><p>A block to sanitize entries. It must accept the value as unique argument.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="Hash.html" title="Lazier::Hash (module)">Hash</a></span></tt>)</span>
—
<div class='inline'><p>If the object is an hash, then the object itself, a hash with the object as single value otherwise.</p>
</div>
</li>
</ul>
<p class="tag_title">See Also:</p>
<ul class="see">
<li><span class='object_link'><a href="Hash.html#ensure_access-instance_method" title="Lazier::Hash#ensure_access (method)">Hash#ensure_access</a></span></li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
125
126
127
128
129
130</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 125</span>
<span class='kw'>def</span> <span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='label'>sanitizer:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_convert_to_hash'>convert_to_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_default'>default</span><span class='rparen'>)</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_sanitize_hash'>sanitize_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_sanitizer'>sanitizer</span><span class='comma'>,</span> <span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_block'>block</span> <span class='op'>||</span> <span class='id identifier rubyid_sanitizer'>sanitizer</span>
<span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:ensure_access</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_ensure_access'>ensure_access</span><span class='lparen'>(</span><span class='id identifier rubyid_accesses'>accesses</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_rv'>rv</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="ensure_string-instance_method">
#<strong>ensure_string</strong>(default = "", conversion_method = :to_s) ⇒ <tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Makes sure that the object is a string.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>default</span>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
<em class="default">(defaults to: <tt>""</tt>)</em>
—
<div class='inline'><p>The default value to return if the object is <code>nil</code>. It is also passed to the block stringifier.</p>
</div>
</li>
<li>
<span class='name'>conversion_method</span>
<span class='type'>(<tt>Symbol</tt>)</span>
<em class="default">(defaults to: <tt>:to_s</tt>)</em>
—
<div class='inline'><p>The method used to convert the object to a string. <em>Ignored if a block is passed.</em></p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
—
<div class='inline'><p>The string representation of the object.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
85
86
87
88
89
90
91</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 85</span>
<span class='kw'>def</span> <span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='lparen'>(</span><span class='id identifier rubyid_default'>default</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_conversion_method'>conversion_method</span> <span class='op'>=</span> <span class='symbol'>:to_s</span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>NilClass</span><span class='rparen'>)</span>
<span class='id identifier rubyid_default'>default</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_block_given?'>block_given?</span> <span class='op'>?</span> <span class='kw'>yield</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_default'>default</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_conversion_method'>conversion_method</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="float?-instance_method">
#<strong>float?</strong> ⇒ <tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Checks if the object is a valid float.</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="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
—
<div class='inline'><p><code>true</code> is a valid float, <code>false</code> otherwise.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
47
48
49</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 47</span>
<span class='kw'>def</span> <span class='id identifier rubyid_float?'>float?</span>
<span class='id identifier rubyid_number?'>number?</span><span class='lparen'>(</span><span class='const'>Numeric</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>Object</span><span class='op'>::</span><span class='const'>FLOAT_MATCHER</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="format_boolean-instance_method">
#<strong>format_boolean</strong>(true_name: nil, false_name: nil) ⇒ <tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Formats a boolean.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>true_name</span>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span>|NilClass</tt>)</span>
—
<div class='inline'><p>The string representation of <code>true</code>. Defaults to <code>Yes</code>.</p>
</div>
</li>
<li>
<span class='name'>false_name</span>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span>|NilClass</tt>)</span>
—
<div class='inline'><p>The string representation of <code>false</code>. Defaults to <code>No</code>.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
—
<div class='inline'><p>The string representation of the object.</p>
</div>
</li>
</ul>
<p class="tag_title">See Also:</p>
<ul class="see">
<li><span class='object_link'><a href="Settings.html#setup_boolean_names-instance_method" title="Lazier::Settings#setup_boolean_names (method)">Settings#setup_boolean_names</a></span></li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
209
210
211
212</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 209</span>
<span class='kw'>def</span> <span class='id identifier rubyid_format_boolean'>format_boolean</span><span class='lparen'>(</span><span class='label'>true_name:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>false_name:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='id identifier rubyid_settings'>settings</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='period'>.</span><span class='id identifier rubyid_settings'>settings</span><span class='period'>.</span><span class='id identifier rubyid_boolean_names'>boolean_names</span>
<span class='id identifier rubyid_to_boolean'>to_boolean</span> <span class='op'>?</span> <span class='lparen'>(</span><span class='id identifier rubyid_true_name'>true_name</span> <span class='op'>||</span> <span class='id identifier rubyid_settings'>settings</span><span class='lbracket'>[</span><span class='kw'>true</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='lparen'>(</span><span class='id identifier rubyid_false_name'>false_name</span> <span class='op'>||</span> <span class='id identifier rubyid_settings'>settings</span><span class='lbracket'>[</span><span class='kw'>false</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="format_number-instance_method">
#<strong>format_number</strong>(precision: nil, decimal_separator: nil, add_string: nil, k_separator: nil) ⇒ <tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span>|NilClass</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Formats a number.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>precision</span>
<span class='type'>(<tt>Fixnum|NilClass</tt>)</span>
—
<div class='inline'><p>The precision to show.</p>
</div>
</li>
<li>
<span class='name'>decimal_separator</span>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span>|NilClass</tt>)</span>
—
<div class='inline'><p>The string to use as decimal separator.</p>
</div>
</li>
<li>
<span class='name'>add_string</span>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span>|NilClass</tt>)</span>
—
<div class='inline'><p>The string to append to the number.</p>
</div>
</li>
<li>
<span class='name'>k_separator</span>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span>|NilClass</tt>)</span>
—
<div class='inline'><p>The string to use as thousands separator.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span>|NilClass</tt>)</span>
—
<div class='inline'><p>The string representation of the object or <code>nil</code>, if the object is not a number.</p>
</div>
</li>
</ul>
<p class="tag_title">See Also:</p>
<ul class="see">
<li><span class='object_link'><a href="Settings.html#setup_format_number-instance_method" title="Lazier::Settings#setup_format_number (method)">Settings#setup_format_number</a></span></li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
192
193
194
195
196
197
198
199
200
201</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 192</span>
<span class='kw'>def</span> <span class='id identifier rubyid_format_number'>format_number</span><span class='lparen'>(</span><span class='label'>precision:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>decimal_separator:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>add_string:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>k_separator:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='id identifier rubyid_number?'>number?</span>
<span class='id identifier rubyid_precision'>precision</span><span class='comma'>,</span> <span class='id identifier rubyid_decimal_separator'>decimal_separator</span><span class='comma'>,</span> <span class='id identifier rubyid_add_string'>add_string</span><span class='comma'>,</span> <span class='id identifier rubyid_k_separator'>k_separator</span> <span class='op'>=</span> <span class='id identifier rubyid_format_number_sanitize'>format_number_sanitize</span><span class='lparen'>(</span><span class='id identifier rubyid_precision'>precision</span><span class='comma'>,</span> <span class='id identifier rubyid_decimal_separator'>decimal_separator</span><span class='comma'>,</span> <span class='id identifier rubyid_add_string'>add_string</span><span class='comma'>,</span> <span class='id identifier rubyid_k_separator'>k_separator</span><span class='rparen'>)</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>%0.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_precision'>precision</span><span class='embexpr_end'>}</span><span class='tstring_content'>f</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_rv'>rv</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_gsub!'>gsub!</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(\d)(?=(\d{3})+(?!\d))</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\\1</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_k_separator'>k_separator</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid_decimal_separator'>decimal_separator</span><span class='rparen'>)</span>
<span class='id identifier rubyid_add_string'>add_string</span> <span class='op'>?</span> <span class='id identifier rubyid_rv'>rv</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_add_string'>add_string</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='op'>:</span> <span class='id identifier rubyid_rv'>rv</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="indexize-instance_method">
#<strong>indexize</strong>(length: 2, filler: "0", formatter: :rjust) ⇒ <tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Prepares an object to be printed in list summaries, like</p>
<pre class="code ruby"><code class="ruby">[01/04] Opening this...
</code></pre>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>length</span>
<span class='type'>(<tt>Fixnum</tt>)</span>
—
<div class='inline'><p>The minimum length of the label.</p>
</div>
</li>
<li>
<span class='name'>filler</span>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
—
<div class='inline'><p>The character to use to fill the label.</p>
</div>
</li>
<li>
<span class='name'>formatter</span>
<span class='type'>(<tt>Symbol</tt>)</span>
—
<div class='inline'><p>The method to use to format the label. Must accept the <code>length</code> and the <code>filler</code> arguments.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
—
<div class='inline'><p>The object inspected and formatted.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
222
223
224</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 222</span>
<span class='kw'>def</span> <span class='id identifier rubyid_indexize'>indexize</span><span class='lparen'>(</span><span class='label'>length:</span> <span class='int'>2</span><span class='comma'>,</span> <span class='label'>filler:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>0</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>formatter:</span> <span class='symbol'>:rjust</span><span class='rparen'>)</span>
<span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_formatter'>formatter</span><span class='comma'>,</span> <span class='id identifier rubyid_length'>length</span><span class='comma'>,</span> <span class='id identifier rubyid_filler'>filler</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="integer?-instance_method">
#<strong>integer?</strong> ⇒ <tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Checks if the object is a valid integer.</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="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
—
<div class='inline'><p><code>true</code> is a valid integer, <code>false</code> otherwise.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
40
41
42</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 40</span>
<span class='kw'>def</span> <span class='id identifier rubyid_integer?'>integer?</span>
<span class='id identifier rubyid_number?'>number?</span><span class='lparen'>(</span><span class='const'>Integer</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>Object</span><span class='op'>::</span><span class='const'>INTEGER_MATCHER</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="normalize_number-instance_method">
#<strong>normalize_number</strong> ⇒ <tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Normalizes a number for conversion. Basically this methods removes all separator and ensures that <code>.</code> is used for decimal separator.</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="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
—
<div class='inline'><p>The normalized number.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
26
27
28</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 26</span>
<span class='kw'>def</span> <span class='id identifier rubyid_normalize_number'>normalize_number</span>
<span class='id identifier rubyid_boolean?'>boolean?</span> <span class='op'>?</span> <span class='id identifier rubyid_to_i'>to_i</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='op'>:</span> <span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>[\.,](?=(.*[\.,]))</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>,</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="number?-instance_method">
#<strong>number?</strong>(klass = Integer, matcher = ::Lazier::Object::FLOAT_MATCHER) ⇒ <tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Checks if the object is of a numeric class of matches a numeric string expression.</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="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
—
<div class='inline'><p><code>true</code> is a valid numeric object, <code>false</code> otherwise.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
33
34
35</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 33</span>
<span class='kw'>def</span> <span class='id identifier rubyid_number?'>number?</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span> <span class='op'>=</span> <span class='const'>Integer</span><span class='comma'>,</span> <span class='id identifier rubyid_matcher'>matcher</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>Object</span><span class='op'>::</span><span class='const'>FLOAT_MATCHER</span><span class='rparen'>)</span>
<span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_boolean?'>boolean?</span> <span class='op'>||</span> <span class='id identifier rubyid_normalize_number'>normalize_number</span> <span class='op'>=~</span> <span class='id identifier rubyid_matcher'>matcher</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="round_to_precision-instance_method">
#<strong>round_to_precision</strong>(precision = 2) ⇒ <tt>Float</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the rounded float representaton of the object.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>precision</span>
<span class='type'>(<tt>Fixnum</tt>)</span>
<em class="default">(defaults to: <tt>2</tt>)</em>
—
<div class='inline'><p>The precision to keep.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Float</tt>)</span>
—
<div class='inline'><p>The rounded float representaton of the object.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
180
181
182</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 180</span>
<span class='kw'>def</span> <span class='id identifier rubyid_round_to_precision'>round_to_precision</span><span class='lparen'>(</span><span class='id identifier rubyid_precision'>precision</span> <span class='op'>=</span> <span class='int'>2</span><span class='rparen'>)</span>
<span class='id identifier rubyid_number?'>number?</span> <span class='op'>?</span> <span class='id identifier rubyid_to_float'>to_float</span><span class='period'>.</span><span class='id identifier rubyid_round'>round</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='id identifier rubyid_precision'>precision</span><span class='comma'>,</span> <span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="safe_send-instance_method">
#<strong>safe_send</strong>(method, *args, &block) ⇒ <tt><span class='object_link'><a href="" title="Lazier::Object (module)">Object</a></span>|nil</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Sends a method to the object. If the objects doesn’t not respond to the method, it returns <code>nil</code> instead of raising an exception.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>method</span>
<span class='type'>(<tt>Symbol</tt>)</span>
—
<div class='inline'><p>The method to send.</p>
</div>
</li>
<li>
<span class='name'>args</span>
<span class='type'>(<tt>Array</tt>)</span>
—
<div class='inline'><p>The arguments to send.</p>
</div>
</li>
<li>
<span class='name'>block</span>
<span class='type'>(<tt>Proc</tt>)</span>
—
<div class='inline'><p>The block to pass to the method.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="" title="Lazier::Object (module)">Object</a></span>|nil</tt>)</span>
—
<div class='inline'><p>The return value of the method or <code>nil</code>, if the object does not respond to the method.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
64
65
66
67
68</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 64</span>
<span class='kw'>def</span> <span class='id identifier rubyid_safe_send'>safe_send</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>rescue</span> <span class='const'>NoMethodError</span>
<span class='kw'>nil</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="to_boolean-instance_method">
#<strong>to_boolean</strong> ⇒ <tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Converts the object to a boolean.</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="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
—
<div class='inline'><p>The boolean representation of the object.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
135
136
137</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 135</span>
<span class='kw'>def</span> <span class='id identifier rubyid_to_boolean'>to_boolean</span>
<span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>TrueClass</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_to_integer'>to_integer</span> <span class='op'>==</span> <span class='int'>1</span> <span class='op'>||</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>Object</span><span class='op'>::</span><span class='const'>BOOLEAN_TRUE_MATCHER</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>MatchData</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="to_debug-instance_method">
#<strong>to_debug</strong>(format: :pretty_json, as_exception: true) ⇒ <tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Inspects an object.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>format</span>
<span class='type'></span>
—
<div class='inline'><p>The format to use. If different from <code>:pretty_json</code>, the object must respond to the <code>to_#{format}</code> method.</p>
</div>
</li>
<li>
<span class='name'>as_exception</span>
<span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
—
<div class='inline'><p>If raise an exception.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
—
<div class='inline'><p>The object inspected and formatted.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
171
172
173
174</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 171</span>
<span class='kw'>def</span> <span class='id identifier rubyid_to_debug'>to_debug</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='symbol'>:pretty_json</span><span class='comma'>,</span> <span class='label'>as_exception:</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>to_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_format'>format</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_as_exception'>as_exception</span> <span class='op'>?</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>Debug</span><span class='comma'>,</span> <span class='id identifier rubyid_rv'>rv</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_rv'>rv</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="to_float-instance_method">
#<strong>to_float</strong>(default = 0.0) ⇒ <tt>Float</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Converts the object to a float.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>default</span>
<span class='type'>(<tt>Float</tt>)</span>
<em class="default">(defaults to: <tt>0.0</tt>)</em>
—
<div class='inline'><p>The value to return if the conversion is not possible.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Float</tt>)</span>
—
<div class='inline'><p>The float representation of the object.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
151
152
153
154
155
156
157</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 151</span>
<span class='kw'>def</span> <span class='id identifier rubyid_to_float'>to_float</span><span class='lparen'>(</span><span class='id identifier rubyid_default'>default</span> <span class='op'>=</span> <span class='float'>0.0</span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='id identifier rubyid_float?'>float?</span>
<span class='op'>::</span><span class='const'>Kernel</span><span class='period'>.</span><span class='const'>Float</span><span class='lparen'>(</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Numeric</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='kw'>self</span> <span class='op'>:</span> <span class='id identifier rubyid_normalize_number'>normalize_number</span><span class='rparen'>)</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_default'>default</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="to_integer-instance_method">
#<strong>to_integer</strong>(default = 0) ⇒ <tt>Fixnum</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Converts the object to a integer.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>default</span>
<span class='type'>(<tt>Fixnum</tt>)</span>
<em class="default">(defaults to: <tt>0</tt>)</em>
—
<div class='inline'><p>The value to return if the conversion is not possible.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Fixnum</tt>)</span>
—
<div class='inline'><p>The integer representation of the object.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
143
144
145</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 143</span>
<span class='kw'>def</span> <span class='id identifier rubyid_to_integer'>to_integer</span><span class='lparen'>(</span><span class='id identifier rubyid_default'>default</span> <span class='op'>=</span> <span class='int'>0</span><span class='rparen'>)</span>
<span class='id identifier rubyid_to_float'>to_float</span><span class='lparen'>(</span><span class='id identifier rubyid_default'>default</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="to_pretty_json-instance_method">
#<strong>to_pretty_json</strong> ⇒ <tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Converts an object to a pretty formatted JSON string.</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="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
—
<div class='inline'><p>The object as a pretty JSON string.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
162
163
164</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/object.rb', line 162</span>
<span class='kw'>def</span> <span class='id identifier rubyid_to_pretty_json'>to_pretty_json</span>
<span class='const'>Lazier</span><span class='period'>.</span><span class='id identifier rubyid_platform'>platform</span> <span class='op'>!=</span> <span class='symbol'>:java</span> <span class='op'>?</span> <span class='const'>Oj</span><span class='period'>.</span><span class='id identifier rubyid_dump'>dump</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='label'>mode:</span> <span class='symbol'>:compat</span><span class='comma'>,</span> <span class='label'>indent:</span> <span class='int'>2</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='op'>::</span><span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_pretty_generate'>pretty_generate</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Thu Nov 10 11:39:24 2016 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.5 (ruby-2.3.0).
</div>
</div>
</body>
</html>