ShogunPanda/bovem

View on GitHub
docs/Bovem/ConsoleMethods/Interactions.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
  Module: Bovem::ConsoleMethods::Interactions
  
    &mdash; 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::Interactions";
  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 (I)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../../Bovem.html" title="Bovem (module)">Bovem</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../ConsoleMethods.html" title="Bovem::ConsoleMethods (module)">ConsoleMethods</a></span></span>
     &raquo; 
    <span class="title">Interactions</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::Interactions
  
  
  
</h1>
<div class="box_info">
  

  
  
  <dl>
      <dt>Extended by:</dt>
      <dd>ActiveSupport::Concern</dd>
  </dl>
  
  
  
  

  
  <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 to interact with the user and other processes.</p>


  </div>
</div>
<div class="tags">
  

</div><h2>Defined Under Namespace</h2>
<p class="children">
  
    
      <strong class="modules">Modules:</strong> <span class='object_link'><a href="Interactions/ClassMethods.html" title="Bovem::ConsoleMethods::Interactions::ClassMethods (module)">ClassMethods</a></span>
    
  
    
  
</p>







  
    <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="#read-instance_method" title="#read (instance method)">#<strong>read</strong>(prompt: true, default_value: nil, validator: nil, echo: true)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Reads a string from the console.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#task-instance_method" title="#task (instance method)">#<strong>task</strong>(message = nil, suffix: &quot;\n&quot;, indented: true, wrap: false, plain: false, indented_banner: false, full_colored: false, block_indentation: 2, block_indentation_absolute: false)  &#x21d2; Symbol </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Executes a block of code in a indentation region and then prints out and ending status message.</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="read-instance_method">
  
    #<strong>read</strong>(prompt: true, default_value: nil, validator: nil, echo: true)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Reads a string from the console.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>prompt</span>
      
      
        <span class='type'>(<tt>String|Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>A prompt to show. If <code>true</code>, <code>Please insert a value:</code> will be used, if <code>nil</code> or <code>false</code> no prompt will be shown.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>default_value</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>Default value if user simply pressed the enter key.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>validator</span>
      
      
        <span class='type'>(<tt>Array|Regexp</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>An array of values or a Regexp to match the submitted value against.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>echo</span>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>If to show submitted text to the user. <strong>Not supported and thus ignored on Rubinius.</strong></p>
</div>
      
    </li>
  
</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


564
565
566
567
568
569
570
571
572
573
574
575
576
577
578</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/console.rb', line 564</span>

<span class='kw'>def</span> <span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='label'>prompt:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>default_value:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>validator:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>echo:</span> <span class='kw'>true</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_prompt'>prompt</span> <span class='op'>=</span> <span class='id identifier rubyid_sanitize_prompt'>sanitize_prompt</span><span class='lparen'>(</span><span class='id identifier rubyid_prompt'>prompt</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_validator'>validator</span> <span class='op'>=</span> <span class='id identifier rubyid_sanitize_validator'>sanitize_validator</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>

  <span class='kw'>begin</span>
    <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:reply</span><span class='rparen'>)</span> <span class='kw'>do</span>
      <span class='id identifier rubyid_loop'>loop</span> <span class='kw'>do</span>
        <span class='id identifier rubyid_reply'>reply</span> <span class='op'>=</span> <span class='id identifier rubyid_validate_input_value'>validate_input_value</span><span class='lparen'>(</span><span class='id identifier rubyid_read_input_value'>read_input_value</span><span class='lparen'>(</span><span class='id identifier rubyid_prompt'>prompt</span><span class='comma'>,</span> <span class='id identifier rubyid_echo'>echo</span><span class='comma'>,</span> <span class='id identifier rubyid_default_value'>default_value</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
        <span class='id identifier rubyid_handle_reply'>handle_reply</span><span class='lparen'>(</span><span class='id identifier rubyid_reply'>reply</span><span class='rparen'>)</span>
      <span class='kw'>end</span>
    <span class='kw'>end</span>
  <span class='kw'>rescue</span> <span class='const'>Interrupt</span>
    <span class='id identifier rubyid_default_value'>default_value</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="task-instance_method">
  
    #<strong>task</strong>(message = nil, suffix: &quot;\n&quot;, indented: true, wrap: false, plain: false, indented_banner: false, full_colored: false, block_indentation: 2, block_indentation_absolute: false)  &#x21d2; <tt>Symbol</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Executes a block of code in a indentation region and then prints out and ending status 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>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>The message to format.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>suffix</span>
      
      
        <span class='type'>(<tt>Object</tt>)</span>
      
      
      
        &mdash;
        <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>
      
      
      
        &mdash;
        <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>
      
      
      
        &mdash;
        <div class='inline'><p>If not <code>nil</code> or <code>false</code>, the maximum length of a line for wrapped text. <code>true</code> means the current line width.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>plain</span>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>If ignore color markers into the message.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>indented_banner</span>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>If also the banner should be indented.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>full_colored</span>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>If the banner should be fully colored.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>block_indentation</span>
      
      
        <span class='type'>(<tt>Fixnum</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The new width for the indented region.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>block_indentation_absolute</span>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <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>Symbol</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The exit status for the block.</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/console.rb', line 593</span>

<span class='kw'>def</span> <span class='id identifier rubyid_task'>task</span><span class='lparen'>(</span>
  <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>suffix:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</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'>false</span><span class='comma'>,</span> <span class='label'>plain:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>indented_banner:</span> <span class='kw'>false</span><span class='comma'>,</span>
  <span class='label'>full_colored:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>block_indentation:</span> <span class='int'>2</span><span class='comma'>,</span> <span class='label'>block_indentation_absolute:</span> <span class='kw'>false</span>
<span class='rparen'>)</span>
  <span class='id identifier rubyid_status'>status</span> <span class='op'>=</span> <span class='kw'>nil</span>

  <span class='kw'>if</span> <span class='id identifier rubyid_message'>message</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_begin'>begin</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='label'>suffix:</span> <span class='id identifier rubyid_suffix'>suffix</span><span class='comma'>,</span> <span class='label'>indented:</span> <span class='id identifier rubyid_indented'>indented</span><span class='comma'>,</span> <span class='label'>wrap:</span> <span class='id identifier rubyid_wrap'>wrap</span><span class='comma'>,</span> <span class='label'>plain:</span> <span class='id identifier rubyid_plain'>plain</span><span class='comma'>,</span> <span class='label'>indented_banner:</span> <span class='id identifier rubyid_indented_banner'>indented_banner</span><span class='comma'>,</span> <span class='label'>full_colored:</span> <span class='id identifier rubyid_full_colored'>full_colored</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_with_indentation'>with_indentation</span><span class='lparen'>(</span><span class='id identifier rubyid_block_indentation'>block_indentation</span><span class='comma'>,</span> <span class='id identifier rubyid_block_indentation_absolute'>block_indentation_absolute</span><span class='rparen'>)</span> <span class='kw'>do</span>
    <span class='id identifier rubyid_rv'>rv</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='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span> <span class='op'>:</span> <span class='lbracket'>[</span><span class='symbol'>:ok</span><span class='rbracket'>]</span> <span class='comment'># Execute block
</span>    <span class='id identifier rubyid_exit_task'>exit_task</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span><span class='comma'>,</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'># Handle task exit
</span>    <span class='id identifier rubyid_status'>status</span> <span class='op'>=</span> <span class='id identifier rubyid_rv'>rv</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='comment'># Return value
</span>  <span class='kw'>end</span>

  <span class='id identifier rubyid_status'>status</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>