docs/Bovem/ConsoleMethods/Output.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Module: Bovem::ConsoleMethods::Output
— Documentation by YARD 0.9.7
</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 = "Bovem::ConsoleMethods::Output";
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?1"></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="../../Bovem.html" title="Bovem (module)">Bovem</a></span></span> » <span class='title'><span class='object_link'><a href="../ConsoleMethods.html" title="Bovem::ConsoleMethods (module)">ConsoleMethods</a></span></span>
»
<span class="title">Output</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>
<div id="content"><h1>Module: Bovem::ConsoleMethods::Output
</h1>
<div class="box_info">
<dl>
<dt>Included in:</dt>
<dd><span class='object_link'><a href="../Console.html" title="Bovem::Console (class)">Bovem::Console</a></span></dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/bovem/console.rb</dd>
</dl>
</div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>Methods for formatting output messages.</p>
</div>
</div>
<div class="tags">
</div>
<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="#emphasize-instance_method" title="#emphasize (instance method)">#<strong>emphasize</strong>(message, style = "bright") ⇒ String </a>
</span>
<span class="summary_desc"><div class='inline'><p>Embeds a message in a style.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#format-instance_method" title="#format (instance method)">#<strong>format</strong>(message, suffix: "\n", indented: true, wrap: true, plain: false) ⇒ String </a>
</span>
<span class="summary_desc"><div class='inline'><p>Formats a message.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#format_right-instance_method" title="#format_right (instance method)">#<strong>format_right</strong>(message, width: true, go_up: true, plain: false) ⇒ String </a>
</span>
<span class="summary_desc"><div class='inline'><p>Formats a message to be written right-aligned.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#indent-instance_method" title="#indent (instance method)">#<strong>indent</strong>(message, width = true, newline_separator = "\n") ⇒ String </a>
</span>
<span class="summary_desc"><div class='inline'><p>Indents a message.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#reset_indentation-instance_method" title="#reset_indentation (instance method)">#<strong>reset_indentation</strong> ⇒ Fixnum </a>
</span>
<span class="summary_desc"><div class='inline'><p>Resets indentation width to <code>0</code>.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#set_indentation-instance_method" title="#set_indentation (instance method)">#<strong>set_indentation</strong>(width, is_absolute = false) ⇒ Fixnum </a>
</span>
<span class="summary_desc"><div class='inline'><p>Sets the new indentation width.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#with_indentation-instance_method" title="#with_indentation (instance method)">#<strong>with_indentation</strong>(width = 3, is_absolute = false) ⇒ Fixnum </a>
</span>
<span class="summary_desc"><div class='inline'><p>Starts a indented region of text.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#wrap-instance_method" title="#wrap (instance method)">#<strong>wrap</strong>(message, width = nil) ⇒ String </a>
</span>
<span class="summary_desc"><div class='inline'><p>Wraps a message in fixed line width.</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="emphasize-instance_method">
#<strong>emphasize</strong>(message, style = "bright") ⇒ <tt>String</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Embeds a message in a style.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>message</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>The message to emphasize.</p>
</div>
</li>
<li>
<span class='name'>style</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>"bright"</tt>)</em>
—
<div class='inline'><p>The style to use.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>The emphasized message.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
244
245
246</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/console.rb', line 244</span>
<span class='kw'>def</span> <span class='id identifier rubyid_emphasize'>emphasize</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='id identifier rubyid_style'>style</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>bright</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>{mark=</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_style'>style</span><span class='embexpr_end'>}</span><span class='tstring_content'>}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_message'>message</span><span class='embexpr_end'>}</span><span class='tstring_content'>{/mark}</span><span class='tstring_end'>"</span></span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="format-instance_method">
#<strong>format</strong>(message, suffix: "\n", indented: true, wrap: true, plain: false) ⇒ <tt>String</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Formats a message.</p>
<p>You can style text by using <code>{mark}</code> and <code>{/mark}</code> syntax.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>message</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>The message to format.</p>
</div>
</li>
<li>
<span class='name'>suffix</span>
<span class='type'>(<tt>Object</tt>)</span>
—
<div class='inline'><p>If not <code>nil</code> or <code>false</code>, a suffix to add to the message. <code>true</code> means to add <code>\n</code>.</p>
</div>
</li>
<li>
<span class='name'>indented</span>
<span class='type'>(<tt>Object</tt>)</span>
—
<div class='inline'><p>If not <code>nil</code> or <code>false</code>, the width to use for indentation. <code>true</code> means to use the current indentation,
a negative value of <code>-x</code> will indent of <code>x</code> absolute spaces.</p>
</div>
</li>
<li>
<span class='name'>wrap</span>
<span class='type'>(<tt>Object</tt>)</span>
—
<div class='inline'><p>If not <code>nil</code> or <code>false</code>, the maximum length of a line. <code>true</code> means the current line width.</p>
</div>
</li>
<li>
<span class='name'>plain</span>
<span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p>If ignore color markers into the message.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>The formatted message.</p>
</div>
</li>
</ul>
<p class="tag_title">See Also:</p>
<ul class="see">
<li>#replace_markers</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
207
208
209
210
211
212
213
214
215
216
217
218</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/console.rb', line 207</span>
<span class='kw'>def</span> <span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='label'>suffix:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>indented:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>wrap:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>plain:</span> <span class='kw'>false</span><span class='rparen'>)</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_message'>message</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_replace_markers'>replace_markers</span><span class='lparen'>(</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_plain'>plain</span><span class='rparen'>)</span> <span class='comment'># Replace markers
</span>
<span class='comment'># Compute the real width available for the screen, if we both indent and wrap
</span> <span class='id identifier rubyid_wrap'>wrap</span> <span class='op'>=</span> <span class='id identifier rubyid_compute_wrap'>compute_wrap</span><span class='lparen'>(</span><span class='id identifier rubyid_indented'>indented</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_wrap'>wrap</span><span class='period'>.</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='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_indent'>indent</span><span class='lparen'>(</span><span class='id identifier rubyid_wrap'>wrap</span><span class='lparen'>(</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_wrap'>wrap</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_indented'>indented</span><span class='rparen'>)</span> <span class='comment'># Wrap & Indent
</span> <span class='id identifier rubyid_rv'>rv</span> <span class='op'>+=</span> <span class='lparen'>(</span><span class='id identifier rubyid_suffix'>suffix</span><span class='period'>.</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='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span> <span class='op'>:</span> <span class='id identifier rubyid_suffix'>suffix</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_suffix'>suffix</span> <span class='comment'># Add the suffix
</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="format_right-instance_method">
#<strong>format_right</strong>(message, width: true, go_up: true, plain: false) ⇒ <tt>String</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Formats a message to be written right-aligned.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>message</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>The message to format.</p>
</div>
</li>
<li>
<span class='name'>width</span>
<span class='type'>(<tt>Fixnum</tt>)</span>
—
<div class='inline'><p>The screen width. If <code>true</code>, it is automatically computed.</p>
</div>
</li>
<li>
<span class='name'>go_up</span>
<span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p>If go up one line before formatting.</p>
</div>
</li>
<li>
<span class='name'>plain</span>
<span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p>If ignore color markers into the message.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>The formatted message.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
227
228
229
230
231
232
233
234
235
236
237</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/console.rb', line 227</span>
<span class='kw'>def</span> <span class='id identifier rubyid_format_right'>format_right</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='label'>width:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>go_up:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>plain:</span> <span class='kw'>false</span><span class='rparen'>)</span>
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='id identifier rubyid_replace_markers'>replace_markers</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='id identifier rubyid_plain'>plain</span><span class='rparen'>)</span>
<span class='id identifier rubyid_width'>width</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_width'>width</span> <span class='op'>==</span> <span class='kw'>true</span> <span class='op'>||</span> <span class='id identifier rubyid_width'>width</span><span class='period'>.</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='id identifier rubyid_line_width'>line_width</span> <span class='op'>:</span> <span class='id identifier rubyid_to_integer'>to_integer</span><span class='rparen'>)</span>
<span class='comment'># Get padding
</span> <span class='id identifier rubyid_padding'>padding</span> <span class='op'>=</span> <span class='id identifier rubyid_width'>width</span> <span class='op'>-</span> <span class='id identifier rubyid_message'>message</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</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'>(\e\[[0-9]*[a-z]?)|(\\n)</span><span class='regexp_end'>/i</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_length'>length</span>
<span class='comment'># Return
</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_go_up'>go_up</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\e[A</span><span class='tstring_end'>"</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span><span class='embexpr_end'>}</span><span class='tstring_content'>\e[0G\e[</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_padding'>padding</span><span class='embexpr_end'>}</span><span class='tstring_content'>C</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_message'>message</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="indent-instance_method">
#<strong>indent</strong>(message, width = true, newline_separator = "\n") ⇒ <tt>String</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Indents a message.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>message</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>The message to indent.</p>
</div>
</li>
<li>
<span class='name'>width</span>
<span class='type'>(<tt>Fixnum</tt>)</span>
<em class="default">(defaults to: <tt>true</tt>)</em>
—
<div class='inline'><p>The indentation width. <code>true</code> means to use the current indentation, a negative value of <code>-x</code>
will indent of <code>x</code> absolute spaces. <code>nil</code> or <code>false</code> will skip indentation.</p>
</div>
</li>
<li>
<span class='name'>newline_separator</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>"\n"</tt>)</em>
—
<div class='inline'><p>The character used for newlines.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>The indented message.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
179
180
181
182
183
184
185
186
187
188
189
190
191
192</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/console.rb', line 179</span>
<span class='kw'>def</span> <span class='id identifier rubyid_indent'>indent</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='id identifier rubyid_width'>width</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_newline_separator'>newline_separator</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='id identifier rubyid_width'>width</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span> <span class='op'>!=</span> <span class='int'>0</span>
<span class='id identifier rubyid_width'>width</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_width'>width</span><span class='period'>.</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='int'>0</span> <span class='op'>:</span> <span class='id identifier rubyid_width'>width</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span><span class='rparen'>)</span>
<span class='id identifier rubyid_width'>width</span> <span class='op'>=</span> <span class='id identifier rubyid_width'>width</span> <span class='op'><</span> <span class='int'>0</span> <span class='op'>?</span> <span class='op'>-</span><span class='id identifier rubyid_width'>width</span> <span class='op'>:</span> <span class='ivar'>@indentation</span> <span class='op'>+</span> <span class='id identifier rubyid_width'>width</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_message'>message</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='id identifier rubyid_newline_separator'>newline_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_line'>line</span><span class='op'>|</span>
<span class='lparen'>(</span><span class='ivar'>@indentation_string</span> <span class='op'>*</span> <span class='id identifier rubyid_width'>width</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='id identifier rubyid_line'>line</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_message'>message</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_newline_separator'>newline_separator</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_message'>message</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="reset_indentation-instance_method">
#<strong>reset_indentation</strong> ⇒ <tt>Fixnum</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Resets indentation width to <code>0</code>.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Fixnum</tt>)</span>
—
<div class='inline'><p>The new indentation width.</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/bovem/console.rb', line 135</span>
<span class='kw'>def</span> <span class='id identifier rubyid_reset_indentation'>reset_indentation</span>
<span class='ivar'>@indentation</span> <span class='op'>=</span> <span class='int'>0</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="set_indentation-instance_method">
#<strong>set_indentation</strong>(width, is_absolute = false) ⇒ <tt>Fixnum</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Sets the new indentation width.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>width</span>
<span class='type'>(<tt>Fixnum</tt>)</span>
—
<div class='inline'><p>The new width.</p>
</div>
</li>
<li>
<span class='name'>is_absolute</span>
<span class='type'>(<tt>Boolean</tt>)</span>
<em class="default">(defaults to: <tt>false</tt>)</em>
—
<div class='inline'><p>If the new width should not be added to the current one but rather replace it.</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 new indentation width.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
128
129
130</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/console.rb', line 128</span>
<span class='kw'>def</span> <span class='id identifier rubyid_set_indentation'>set_indentation</span><span class='lparen'>(</span><span class='id identifier rubyid_width'>width</span><span class='comma'>,</span> <span class='id identifier rubyid_is_absolute'>is_absolute</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
<span class='ivar'>@indentation</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_is_absolute'>is_absolute</span> <span class='op'>?</span> <span class='ivar'>@indentation</span> <span class='op'>:</span> <span class='int'>0</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='id identifier rubyid_width'>width</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='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="with_indentation-instance_method">
#<strong>with_indentation</strong>(width = 3, is_absolute = false) ⇒ <tt>Fixnum</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Starts a indented region of text.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>width</span>
<span class='type'>(<tt>Fixnum</tt>)</span>
<em class="default">(defaults to: <tt>3</tt>)</em>
—
<div class='inline'><p>The new width.</p>
</div>
</li>
<li>
<span class='name'>is_absolute</span>
<span class='type'>(<tt>Boolean</tt>)</span>
<em class="default">(defaults to: <tt>false</tt>)</em>
—
<div class='inline'><p>If the new width should not be added to the current one but rather replace it.</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 new indentation width.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
144
145
146
147
148
149
150
151</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/console.rb', line 144</span>
<span class='kw'>def</span> <span class='id identifier rubyid_with_indentation'>with_indentation</span><span class='lparen'>(</span><span class='id identifier rubyid_width'>width</span> <span class='op'>=</span> <span class='int'>3</span><span class='comma'>,</span> <span class='id identifier rubyid_is_absolute'>is_absolute</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
<span class='id identifier rubyid_old'>old</span> <span class='op'>=</span> <span class='ivar'>@indentation</span>
<span class='id identifier rubyid_set_indentation'>set_indentation</span><span class='lparen'>(</span><span class='id identifier rubyid_width'>width</span><span class='comma'>,</span> <span class='id identifier rubyid_is_absolute'>is_absolute</span><span class='rparen'>)</span>
<span class='kw'>yield</span>
<span class='id identifier rubyid_set_indentation'>set_indentation</span><span class='lparen'>(</span><span class='id identifier rubyid_old'>old</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='ivar'>@indentation</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="wrap-instance_method">
#<strong>wrap</strong>(message, width = nil) ⇒ <tt>String</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Wraps a message in fixed line width.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>message</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>The message to wrap.</p>
</div>
</li>
<li>
<span class='name'>width</span>
<span class='type'>(<tt>Fixnum</tt>)</span>
<em class="default">(defaults to: <tt>nil</tt>)</em>
—
<div class='inline'><p>The maximum width of a line. Default to the current line width.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>The wrapped message.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
158
159
160
161
162
163
164
165
166
167
168
169
170</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/console.rb', line 158</span>
<span class='kw'>def</span> <span class='id identifier rubyid_wrap'>wrap</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='id identifier rubyid_width'>width</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='id identifier rubyid_width'>width</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span> <span class='op'><=</span> <span class='int'>0</span>
<span class='id identifier rubyid_message'>message</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_width'>width</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_width'>width</span> <span class='op'>==</span> <span class='kw'>true</span> <span class='op'>||</span> <span class='id identifier rubyid_width'>width</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span> <span class='op'><</span> <span class='int'>0</span> <span class='op'>?</span> <span class='id identifier rubyid_line_width'>line_width</span> <span class='op'>:</span> <span class='id identifier rubyid_width'>width</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span><span class='rparen'>)</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_message'>message</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'>\n</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_line'>line</span><span class='op'>|</span>
<span class='id identifier rubyid_wrap_line'>wrap_line</span><span class='lparen'>(</span><span class='id identifier rubyid_line'>line</span><span class='comma'>,</span> <span class='id identifier rubyid_width'>width</span><span class='rparen'>)</span>
<span class='kw'>end</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='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></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 Thu Jan 12 16:10:58 2017 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.7 (ruby-2.3.0).
</div>
</div>
</body>
</html>