ShogunPanda/bovem

View on GitHub
docs/Bovem/Option.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>
  Class: Bovem::Option
  
    &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::Option";
  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> &raquo;
    <span class='title'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span>
     &raquo; 
    <span class="title">Option</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>Class: Bovem::Option
  
  
  
</h1>
<div class="box_info">
  
  <dl>
    <dt>Inherits:</dt>
    <dd>
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">Bovem::Option</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
    </dd>
  </dl>
  

  
  
  
  
  

  

  
  <dl>
    <dt>Defined in:</dt>
    <dd>lib/bovem/option.rb</dd>
  </dl>
  
</div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>This class represents an option for a command.</p>


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

</div>



  <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#action-instance_method" title="#action (instance method)">#<strong>action</strong>  &#x21d2; Proc </a>
    

    
  </span>
  
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>The action associated to this option.</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#default-instance_method" title="#default (instance method)">#<strong>default</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Get the current default value for this option.</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#help-instance_method" title="#help (instance method)">#<strong>help</strong>  &#x21d2; String </a>
    

    
  </span>
  
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>An help message for this option.</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#long-instance_method" title="#long (instance method)">#<strong>long</strong>  &#x21d2; String </a>
    

    
  </span>
  
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>The long form (i.e.: <code>--help</code>) for this option.</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#meta-instance_method" title="#meta (instance method)">#<strong>meta</strong>  &#x21d2; String|NilClass </a>
    

    
  </span>
  
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Returns the meta argument for this option.</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#name-instance_method" title="#name (instance method)">#<strong>name</strong>  &#x21d2; String </a>
    

    
  </span>
  
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>The name of this option.</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#parent-instance_method" title="#parent (instance method)">#<strong>parent</strong>  &#x21d2; Command </a>
    

    
  </span>
  
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>The parent of this option.</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#required-instance_method" title="#required (instance method)">#<strong>required</strong>  &#x21d2; Boolean </a>
    

    
  </span>
  
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>If this option is required.</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#short-instance_method" title="#short (instance method)">#<strong>short</strong>  &#x21d2; String </a>
    

    
  </span>
  
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>The short form (i.e.: <code>-h</code>) for this option.</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#type-instance_method" title="#type (instance method)">#<strong>type</strong>  &#x21d2; Class </a>
    

    
  </span>
  
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>The type of this option.</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#validator-instance_method" title="#validator (instance method)">#<strong>validator</strong>  &#x21d2; Array|Regexp </a>
    

    
  </span>
  
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Or A constraint for valid values.</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#value-instance_method" title="#value (instance method)">#<strong>value</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Get the current value for this option.</p>
</div></span>
  
</li>

    
  </ul>




  
    <h2>
      Instance Method Summary
      <small><a href="#" class="summary_toggle">collapse</a></small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#complete_long-instance_method" title="#complete_long (instance method)">#<strong>complete_long</strong>  &#x21d2; String </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Returns the long form with two dashes prepended.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#complete_short-instance_method" title="#complete_short (instance method)">#<strong>complete_short</strong>  &#x21d2; String </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Returns the short form with a dash prepended.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#default%3F-instance_method" title="#default? (instance method)">#<strong>default?</strong>  &#x21d2; Boolean </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Check if the current option has a default value.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#execute_action-instance_method" title="#execute_action (instance method)">#<strong>execute_action</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Executes the action associated to this option.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#help%3F-instance_method" title="#help? (instance method)">#<strong>help?</strong>  &#x21d2; Boolean </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Check if this command has a help.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(name, forms = [], options = {}, &amp;action)  &#x21d2; Option </a>
    

    
  </span>
  
  
    <span class="note title constructor">constructor</span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Creates a new option.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#label-instance_method" title="#label (instance method)">#<strong>label</strong>  &#x21d2; String </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Returns a label for this option, combining short and long forms.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#provided%3F-instance_method" title="#provided? (instance method)">#<strong>provided?</strong>  &#x21d2; Boolean </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>If this option was provided.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#requires_argument%3F-instance_method" title="#requires_argument? (instance method)">#<strong>requires_argument?</strong>  &#x21d2; Boolean </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Checks if this option requires an argument.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#set-instance_method" title="#set (instance method)">#<strong>set</strong>(value, raise_error = true)  &#x21d2; Boolean </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Sets the value of this option and also make sure that it is validated.</p>
</div></span>
  
</li>

      
    </ul>
  

<div id="constructor_details" class="method_details_list">
  <h2>Constructor Details</h2>
  
    <div class="method_details first">
  <h3 class="signature first" id="initialize-instance_method">
  
    #<strong>initialize</strong>(name, forms = [], options = {}, &amp;action)  &#x21d2; <tt><span class='object_link'><a href="" title="Bovem::Option (class)">Option</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Creates a new option.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>name</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The name of this option. Must be unique.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>forms</span>
      
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>[]</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>An array of short and long forms for this option. Missing forms will be inferred by the name.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>options</span>
      
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>{}</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>The settings for this option.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>action</span>
      
      
        <span class='type'>(<tt>Proc</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The action of this option.</p>
</div>
      
    </li>
  
</ul>


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


61
62
63
64
65
66
67</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 61</span>

<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_forms'>forms</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
  <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
  <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
  <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
  
</div>

  <div id="instance_attr_details" class="attr_details">
    <h2>Instance Attribute Details</h2>
    
      
      <span id="action=-instance_method"></span>
      <div class="method_details first">
  <h3 class="signature first" id="action-instance_method">
  
    #<strong>action</strong>  &#x21d2; <tt>Proc</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns The action associated to this option.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Proc</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The action associated to this option.</p>
</div>
      
    </li>
  
</ul>

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


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>

<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Option (class)">Option</a></span></span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:short</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:long</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:type</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:required</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:default</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:meta</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:help</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:value</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:action</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:validator</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:parent</span>

  <span class='comment'># Creates a new option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param name [String] The name of this option. Must be unique.
</span>  <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
</span>  <span class='comment'># @param options [Hash] The settings for this option.
</span>  <span class='comment'># @param action [Proc] The action of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_forms'>forms</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
    <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the short form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@short</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@long</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option. Can be a Object, an Array, a Regexp or a Proc which takes one argument and returns a boolean.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The validator of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
    <span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the short form with a dash prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with a dash prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_short'>complete_short</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>-</span><span class='embexpr_beg'>#{</span><span class='ivar'>@short</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the long form with two dashes prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with two dashes prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_long'>complete_long</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>--</span><span class='embexpr_beg'>#{</span><span class='ivar'>@long</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns a label for this option, combining short and long forms.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] A label for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_label'>label</span>
    <span class='lbracket'>[</span><span class='id identifier rubyid_complete_short'>complete_short</span><span class='comma'>,</span> <span class='id identifier rubyid_complete_long'>complete_long</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the meta argument for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
</span>  <span class='comment'>#   if this option doesn&#39;t require a meta argument.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current default value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The default value for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
    <span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Bovem.html#OPTION_TYPES-constant" title="Bovem::OPTION_TYPES (constant)">OPTION_TYPES</a></span></span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if the current option has a default value.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] If the current option has a default value.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
    <span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the value of this option and also make sure that it is validated.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [Object] The new value of this option.
</span>  <span class='comment'># @param raise_error [Boolean] If raise an ArgumentError in case of validation errors.
</span>  <span class='comment'># @return [Boolean] `true` if operation succeeded, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_raise_error'>raise_error</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>

    <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='kw'>else</span> <span class='comment'># Validation failed
</span>      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='kw'>nil</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
      <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_raise_error'>raise_error</span>
      <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># Executes the action associated to this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Checks if this option requires an argument.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option requires an argument, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='lbracket'>[</span><span class='const'>String</span><span class='comma'>,</span> <span class='const'>Integer</span><span class='comma'>,</span> <span class='const'>Float</span><span class='comma'>,</span> <span class='const'>Array</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@type</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
  <span class='kw'>end</span>

  <span class='comment'># If this option was provided.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option was provided, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_provided?'>provided?</span>
    <span class='ivar'>@provided</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if this command has a help.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
    <span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The current value of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span>
    <span class='id identifier rubyid_provided?'>provided?</span> <span class='op'>?</span> <span class='ivar'>@value</span> <span class='op'>:</span> <span class='id identifier rubyid_default'>default</span>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_private'>private</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
      <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>

    <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
      <span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
      <span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>, </span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
      <span class='kw'>end</span>

    <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
    <span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Array</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>include?</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Proc</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>else</span> <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="default=-instance_method"></span>
      <div class="method_details ">
  <h3 class="signature " id="default-instance_method">
  
    #<strong>default</strong>  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Get the current default value for this option.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Object</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The default value for this option.</p>
</div>
      
    </li>
  
</ul>

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


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>

<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Option (class)">Option</a></span></span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:short</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:long</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:type</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:required</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:default</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:meta</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:help</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:value</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:action</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:validator</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:parent</span>

  <span class='comment'># Creates a new option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param name [String] The name of this option. Must be unique.
</span>  <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
</span>  <span class='comment'># @param options [Hash] The settings for this option.
</span>  <span class='comment'># @param action [Proc] The action of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_forms'>forms</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
    <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the short form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@short</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@long</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option. Can be a Object, an Array, a Regexp or a Proc which takes one argument and returns a boolean.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The validator of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
    <span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the short form with a dash prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with a dash prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_short'>complete_short</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>-</span><span class='embexpr_beg'>#{</span><span class='ivar'>@short</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the long form with two dashes prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with two dashes prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_long'>complete_long</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>--</span><span class='embexpr_beg'>#{</span><span class='ivar'>@long</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns a label for this option, combining short and long forms.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] A label for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_label'>label</span>
    <span class='lbracket'>[</span><span class='id identifier rubyid_complete_short'>complete_short</span><span class='comma'>,</span> <span class='id identifier rubyid_complete_long'>complete_long</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the meta argument for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
</span>  <span class='comment'>#   if this option doesn&#39;t require a meta argument.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current default value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The default value for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
    <span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Bovem.html#OPTION_TYPES-constant" title="Bovem::OPTION_TYPES (constant)">OPTION_TYPES</a></span></span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if the current option has a default value.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] If the current option has a default value.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
    <span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the value of this option and also make sure that it is validated.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [Object] The new value of this option.
</span>  <span class='comment'># @param raise_error [Boolean] If raise an ArgumentError in case of validation errors.
</span>  <span class='comment'># @return [Boolean] `true` if operation succeeded, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_raise_error'>raise_error</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>

    <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='kw'>else</span> <span class='comment'># Validation failed
</span>      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='kw'>nil</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
      <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_raise_error'>raise_error</span>
      <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># Executes the action associated to this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Checks if this option requires an argument.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option requires an argument, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='lbracket'>[</span><span class='const'>String</span><span class='comma'>,</span> <span class='const'>Integer</span><span class='comma'>,</span> <span class='const'>Float</span><span class='comma'>,</span> <span class='const'>Array</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@type</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
  <span class='kw'>end</span>

  <span class='comment'># If this option was provided.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option was provided, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_provided?'>provided?</span>
    <span class='ivar'>@provided</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if this command has a help.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
    <span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The current value of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span>
    <span class='id identifier rubyid_provided?'>provided?</span> <span class='op'>?</span> <span class='ivar'>@value</span> <span class='op'>:</span> <span class='id identifier rubyid_default'>default</span>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_private'>private</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
      <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>

    <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
      <span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
      <span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>, </span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
      <span class='kw'>end</span>

    <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
    <span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Array</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>include?</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Proc</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>else</span> <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="help=-instance_method"></span>
      <div class="method_details ">
  <h3 class="signature " id="help-instance_method">
  
    #<strong>help</strong>  &#x21d2; <tt>String</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns An help message for this option.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>An help message for this option.</p>
</div>
      
    </li>
  
</ul>

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


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>

<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Option (class)">Option</a></span></span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:short</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:long</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:type</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:required</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:default</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:meta</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:help</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:value</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:action</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:validator</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:parent</span>

  <span class='comment'># Creates a new option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param name [String] The name of this option. Must be unique.
</span>  <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
</span>  <span class='comment'># @param options [Hash] The settings for this option.
</span>  <span class='comment'># @param action [Proc] The action of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_forms'>forms</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
    <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the short form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@short</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@long</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option. Can be a Object, an Array, a Regexp or a Proc which takes one argument and returns a boolean.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The validator of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
    <span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the short form with a dash prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with a dash prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_short'>complete_short</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>-</span><span class='embexpr_beg'>#{</span><span class='ivar'>@short</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the long form with two dashes prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with two dashes prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_long'>complete_long</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>--</span><span class='embexpr_beg'>#{</span><span class='ivar'>@long</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns a label for this option, combining short and long forms.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] A label for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_label'>label</span>
    <span class='lbracket'>[</span><span class='id identifier rubyid_complete_short'>complete_short</span><span class='comma'>,</span> <span class='id identifier rubyid_complete_long'>complete_long</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the meta argument for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
</span>  <span class='comment'>#   if this option doesn&#39;t require a meta argument.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current default value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The default value for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
    <span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Bovem.html#OPTION_TYPES-constant" title="Bovem::OPTION_TYPES (constant)">OPTION_TYPES</a></span></span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if the current option has a default value.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] If the current option has a default value.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
    <span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the value of this option and also make sure that it is validated.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [Object] The new value of this option.
</span>  <span class='comment'># @param raise_error [Boolean] If raise an ArgumentError in case of validation errors.
</span>  <span class='comment'># @return [Boolean] `true` if operation succeeded, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_raise_error'>raise_error</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>

    <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='kw'>else</span> <span class='comment'># Validation failed
</span>      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='kw'>nil</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
      <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_raise_error'>raise_error</span>
      <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># Executes the action associated to this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Checks if this option requires an argument.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option requires an argument, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='lbracket'>[</span><span class='const'>String</span><span class='comma'>,</span> <span class='const'>Integer</span><span class='comma'>,</span> <span class='const'>Float</span><span class='comma'>,</span> <span class='const'>Array</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@type</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
  <span class='kw'>end</span>

  <span class='comment'># If this option was provided.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option was provided, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_provided?'>provided?</span>
    <span class='ivar'>@provided</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if this command has a help.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
    <span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The current value of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span>
    <span class='id identifier rubyid_provided?'>provided?</span> <span class='op'>?</span> <span class='ivar'>@value</span> <span class='op'>:</span> <span class='id identifier rubyid_default'>default</span>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_private'>private</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
      <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>

    <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
      <span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
      <span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>, </span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
      <span class='kw'>end</span>

    <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
    <span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Array</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>include?</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Proc</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>else</span> <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="long=-instance_method"></span>
      <div class="method_details ">
  <h3 class="signature " id="long-instance_method">
  
    #<strong>long</strong>  &#x21d2; <tt>String</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns The long form (i.e.: <code>--help</code>) for this option.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The long form (i.e.: <code>--help</code>) for this option.</p>
</div>
      
    </li>
  
</ul>

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


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>

<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Option (class)">Option</a></span></span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:short</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:long</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:type</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:required</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:default</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:meta</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:help</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:value</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:action</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:validator</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:parent</span>

  <span class='comment'># Creates a new option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param name [String] The name of this option. Must be unique.
</span>  <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
</span>  <span class='comment'># @param options [Hash] The settings for this option.
</span>  <span class='comment'># @param action [Proc] The action of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_forms'>forms</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
    <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the short form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@short</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@long</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option. Can be a Object, an Array, a Regexp or a Proc which takes one argument and returns a boolean.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The validator of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
    <span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the short form with a dash prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with a dash prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_short'>complete_short</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>-</span><span class='embexpr_beg'>#{</span><span class='ivar'>@short</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the long form with two dashes prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with two dashes prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_long'>complete_long</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>--</span><span class='embexpr_beg'>#{</span><span class='ivar'>@long</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns a label for this option, combining short and long forms.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] A label for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_label'>label</span>
    <span class='lbracket'>[</span><span class='id identifier rubyid_complete_short'>complete_short</span><span class='comma'>,</span> <span class='id identifier rubyid_complete_long'>complete_long</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the meta argument for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
</span>  <span class='comment'>#   if this option doesn&#39;t require a meta argument.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current default value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The default value for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
    <span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Bovem.html#OPTION_TYPES-constant" title="Bovem::OPTION_TYPES (constant)">OPTION_TYPES</a></span></span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if the current option has a default value.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] If the current option has a default value.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
    <span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the value of this option and also make sure that it is validated.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [Object] The new value of this option.
</span>  <span class='comment'># @param raise_error [Boolean] If raise an ArgumentError in case of validation errors.
</span>  <span class='comment'># @return [Boolean] `true` if operation succeeded, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_raise_error'>raise_error</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>

    <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='kw'>else</span> <span class='comment'># Validation failed
</span>      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='kw'>nil</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
      <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_raise_error'>raise_error</span>
      <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># Executes the action associated to this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Checks if this option requires an argument.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option requires an argument, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='lbracket'>[</span><span class='const'>String</span><span class='comma'>,</span> <span class='const'>Integer</span><span class='comma'>,</span> <span class='const'>Float</span><span class='comma'>,</span> <span class='const'>Array</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@type</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
  <span class='kw'>end</span>

  <span class='comment'># If this option was provided.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option was provided, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_provided?'>provided?</span>
    <span class='ivar'>@provided</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if this command has a help.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
    <span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The current value of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span>
    <span class='id identifier rubyid_provided?'>provided?</span> <span class='op'>?</span> <span class='ivar'>@value</span> <span class='op'>:</span> <span class='id identifier rubyid_default'>default</span>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_private'>private</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
      <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>

    <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
      <span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
      <span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>, </span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
      <span class='kw'>end</span>

    <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
    <span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Array</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>include?</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Proc</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>else</span> <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="meta=-instance_method"></span>
      <div class="method_details ">
  <h3 class="signature " id="meta-instance_method">
  
    #<strong>meta</strong>  &#x21d2; <tt>String|NilClass</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns the meta argument for this option.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>String|NilClass</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>Returns the current meta argument for this option (the default value is the option name uppercased) or <code>nil</code>,
if this option doesn’t require a meta argument.</p>
</div>
      
    </li>
  
</ul>

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


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>

<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Option (class)">Option</a></span></span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:short</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:long</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:type</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:required</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:default</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:meta</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:help</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:value</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:action</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:validator</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:parent</span>

  <span class='comment'># Creates a new option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param name [String] The name of this option. Must be unique.
</span>  <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
</span>  <span class='comment'># @param options [Hash] The settings for this option.
</span>  <span class='comment'># @param action [Proc] The action of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_forms'>forms</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
    <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the short form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@short</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@long</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option. Can be a Object, an Array, a Regexp or a Proc which takes one argument and returns a boolean.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The validator of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
    <span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the short form with a dash prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with a dash prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_short'>complete_short</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>-</span><span class='embexpr_beg'>#{</span><span class='ivar'>@short</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the long form with two dashes prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with two dashes prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_long'>complete_long</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>--</span><span class='embexpr_beg'>#{</span><span class='ivar'>@long</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns a label for this option, combining short and long forms.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] A label for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_label'>label</span>
    <span class='lbracket'>[</span><span class='id identifier rubyid_complete_short'>complete_short</span><span class='comma'>,</span> <span class='id identifier rubyid_complete_long'>complete_long</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the meta argument for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
</span>  <span class='comment'>#   if this option doesn&#39;t require a meta argument.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current default value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The default value for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
    <span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Bovem.html#OPTION_TYPES-constant" title="Bovem::OPTION_TYPES (constant)">OPTION_TYPES</a></span></span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if the current option has a default value.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] If the current option has a default value.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
    <span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the value of this option and also make sure that it is validated.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [Object] The new value of this option.
</span>  <span class='comment'># @param raise_error [Boolean] If raise an ArgumentError in case of validation errors.
</span>  <span class='comment'># @return [Boolean] `true` if operation succeeded, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_raise_error'>raise_error</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>

    <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='kw'>else</span> <span class='comment'># Validation failed
</span>      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='kw'>nil</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
      <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_raise_error'>raise_error</span>
      <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># Executes the action associated to this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Checks if this option requires an argument.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option requires an argument, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='lbracket'>[</span><span class='const'>String</span><span class='comma'>,</span> <span class='const'>Integer</span><span class='comma'>,</span> <span class='const'>Float</span><span class='comma'>,</span> <span class='const'>Array</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@type</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
  <span class='kw'>end</span>

  <span class='comment'># If this option was provided.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option was provided, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_provided?'>provided?</span>
    <span class='ivar'>@provided</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if this command has a help.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
    <span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The current value of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span>
    <span class='id identifier rubyid_provided?'>provided?</span> <span class='op'>?</span> <span class='ivar'>@value</span> <span class='op'>:</span> <span class='id identifier rubyid_default'>default</span>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_private'>private</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
      <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>

    <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
      <span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
      <span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>, </span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
      <span class='kw'>end</span>

    <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
    <span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Array</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>include?</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Proc</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>else</span> <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="name=-instance_method"></span>
      <div class="method_details ">
  <h3 class="signature " id="name-instance_method">
  
    #<strong>name</strong>  &#x21d2; <tt>String</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns The name of this option.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The name of this option.</p>
</div>
      
    </li>
  
</ul>

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


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>

<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Option (class)">Option</a></span></span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:short</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:long</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:type</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:required</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:default</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:meta</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:help</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:value</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:action</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:validator</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:parent</span>

  <span class='comment'># Creates a new option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param name [String] The name of this option. Must be unique.
</span>  <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
</span>  <span class='comment'># @param options [Hash] The settings for this option.
</span>  <span class='comment'># @param action [Proc] The action of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_forms'>forms</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
    <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the short form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@short</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@long</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option. Can be a Object, an Array, a Regexp or a Proc which takes one argument and returns a boolean.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The validator of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
    <span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the short form with a dash prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with a dash prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_short'>complete_short</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>-</span><span class='embexpr_beg'>#{</span><span class='ivar'>@short</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the long form with two dashes prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with two dashes prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_long'>complete_long</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>--</span><span class='embexpr_beg'>#{</span><span class='ivar'>@long</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns a label for this option, combining short and long forms.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] A label for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_label'>label</span>
    <span class='lbracket'>[</span><span class='id identifier rubyid_complete_short'>complete_short</span><span class='comma'>,</span> <span class='id identifier rubyid_complete_long'>complete_long</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the meta argument for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
</span>  <span class='comment'>#   if this option doesn&#39;t require a meta argument.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current default value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The default value for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
    <span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Bovem.html#OPTION_TYPES-constant" title="Bovem::OPTION_TYPES (constant)">OPTION_TYPES</a></span></span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if the current option has a default value.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] If the current option has a default value.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
    <span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the value of this option and also make sure that it is validated.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [Object] The new value of this option.
</span>  <span class='comment'># @param raise_error [Boolean] If raise an ArgumentError in case of validation errors.
</span>  <span class='comment'># @return [Boolean] `true` if operation succeeded, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_raise_error'>raise_error</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>

    <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='kw'>else</span> <span class='comment'># Validation failed
</span>      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='kw'>nil</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
      <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_raise_error'>raise_error</span>
      <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># Executes the action associated to this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Checks if this option requires an argument.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option requires an argument, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='lbracket'>[</span><span class='const'>String</span><span class='comma'>,</span> <span class='const'>Integer</span><span class='comma'>,</span> <span class='const'>Float</span><span class='comma'>,</span> <span class='const'>Array</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@type</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
  <span class='kw'>end</span>

  <span class='comment'># If this option was provided.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option was provided, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_provided?'>provided?</span>
    <span class='ivar'>@provided</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if this command has a help.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
    <span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The current value of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span>
    <span class='id identifier rubyid_provided?'>provided?</span> <span class='op'>?</span> <span class='ivar'>@value</span> <span class='op'>:</span> <span class='id identifier rubyid_default'>default</span>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_private'>private</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
      <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>

    <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
      <span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
      <span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>, </span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
      <span class='kw'>end</span>

    <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
    <span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Array</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>include?</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Proc</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>else</span> <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="parent=-instance_method"></span>
      <div class="method_details ">
  <h3 class="signature " id="parent-instance_method">
  
    #<strong>parent</strong>  &#x21d2; <tt><span class='object_link'><a href="Command.html" title="Bovem::Command (class)">Command</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns The parent of this option.</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="Command.html" title="Bovem::Command (class)">Command</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The parent of this option.</p>
</div>
      
    </li>
  
</ul>

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


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>

<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Option (class)">Option</a></span></span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:short</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:long</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:type</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:required</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:default</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:meta</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:help</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:value</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:action</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:validator</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:parent</span>

  <span class='comment'># Creates a new option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param name [String] The name of this option. Must be unique.
</span>  <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
</span>  <span class='comment'># @param options [Hash] The settings for this option.
</span>  <span class='comment'># @param action [Proc] The action of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_forms'>forms</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
    <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the short form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@short</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@long</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option. Can be a Object, an Array, a Regexp or a Proc which takes one argument and returns a boolean.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The validator of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
    <span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the short form with a dash prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with a dash prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_short'>complete_short</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>-</span><span class='embexpr_beg'>#{</span><span class='ivar'>@short</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the long form with two dashes prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with two dashes prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_long'>complete_long</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>--</span><span class='embexpr_beg'>#{</span><span class='ivar'>@long</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns a label for this option, combining short and long forms.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] A label for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_label'>label</span>
    <span class='lbracket'>[</span><span class='id identifier rubyid_complete_short'>complete_short</span><span class='comma'>,</span> <span class='id identifier rubyid_complete_long'>complete_long</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the meta argument for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
</span>  <span class='comment'>#   if this option doesn&#39;t require a meta argument.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current default value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The default value for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
    <span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Bovem.html#OPTION_TYPES-constant" title="Bovem::OPTION_TYPES (constant)">OPTION_TYPES</a></span></span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if the current option has a default value.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] If the current option has a default value.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
    <span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the value of this option and also make sure that it is validated.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [Object] The new value of this option.
</span>  <span class='comment'># @param raise_error [Boolean] If raise an ArgumentError in case of validation errors.
</span>  <span class='comment'># @return [Boolean] `true` if operation succeeded, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_raise_error'>raise_error</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>

    <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='kw'>else</span> <span class='comment'># Validation failed
</span>      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='kw'>nil</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
      <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_raise_error'>raise_error</span>
      <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># Executes the action associated to this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Checks if this option requires an argument.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option requires an argument, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='lbracket'>[</span><span class='const'>String</span><span class='comma'>,</span> <span class='const'>Integer</span><span class='comma'>,</span> <span class='const'>Float</span><span class='comma'>,</span> <span class='const'>Array</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@type</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
  <span class='kw'>end</span>

  <span class='comment'># If this option was provided.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option was provided, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_provided?'>provided?</span>
    <span class='ivar'>@provided</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if this command has a help.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
    <span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The current value of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span>
    <span class='id identifier rubyid_provided?'>provided?</span> <span class='op'>?</span> <span class='ivar'>@value</span> <span class='op'>:</span> <span class='id identifier rubyid_default'>default</span>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_private'>private</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
      <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>

    <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
      <span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
      <span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>, </span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
      <span class='kw'>end</span>

    <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
    <span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Array</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>include?</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Proc</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>else</span> <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="required=-instance_method"></span>
      <div class="method_details ">
  <h3 class="signature " id="required-instance_method">
  
    #<strong>required</strong>  &#x21d2; <tt>Boolean</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns If this option is required.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>If this option is required.</p>
</div>
      
    </li>
  
</ul>

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


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>

<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Option (class)">Option</a></span></span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:short</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:long</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:type</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:required</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:default</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:meta</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:help</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:value</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:action</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:validator</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:parent</span>

  <span class='comment'># Creates a new option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param name [String] The name of this option. Must be unique.
</span>  <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
</span>  <span class='comment'># @param options [Hash] The settings for this option.
</span>  <span class='comment'># @param action [Proc] The action of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_forms'>forms</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
    <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the short form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@short</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@long</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option. Can be a Object, an Array, a Regexp or a Proc which takes one argument and returns a boolean.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The validator of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
    <span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the short form with a dash prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with a dash prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_short'>complete_short</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>-</span><span class='embexpr_beg'>#{</span><span class='ivar'>@short</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the long form with two dashes prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with two dashes prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_long'>complete_long</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>--</span><span class='embexpr_beg'>#{</span><span class='ivar'>@long</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns a label for this option, combining short and long forms.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] A label for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_label'>label</span>
    <span class='lbracket'>[</span><span class='id identifier rubyid_complete_short'>complete_short</span><span class='comma'>,</span> <span class='id identifier rubyid_complete_long'>complete_long</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the meta argument for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
</span>  <span class='comment'>#   if this option doesn&#39;t require a meta argument.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current default value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The default value for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
    <span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Bovem.html#OPTION_TYPES-constant" title="Bovem::OPTION_TYPES (constant)">OPTION_TYPES</a></span></span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if the current option has a default value.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] If the current option has a default value.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
    <span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the value of this option and also make sure that it is validated.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [Object] The new value of this option.
</span>  <span class='comment'># @param raise_error [Boolean] If raise an ArgumentError in case of validation errors.
</span>  <span class='comment'># @return [Boolean] `true` if operation succeeded, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_raise_error'>raise_error</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>

    <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='kw'>else</span> <span class='comment'># Validation failed
</span>      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='kw'>nil</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
      <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_raise_error'>raise_error</span>
      <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># Executes the action associated to this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Checks if this option requires an argument.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option requires an argument, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='lbracket'>[</span><span class='const'>String</span><span class='comma'>,</span> <span class='const'>Integer</span><span class='comma'>,</span> <span class='const'>Float</span><span class='comma'>,</span> <span class='const'>Array</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@type</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
  <span class='kw'>end</span>

  <span class='comment'># If this option was provided.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option was provided, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_provided?'>provided?</span>
    <span class='ivar'>@provided</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if this command has a help.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
    <span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The current value of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span>
    <span class='id identifier rubyid_provided?'>provided?</span> <span class='op'>?</span> <span class='ivar'>@value</span> <span class='op'>:</span> <span class='id identifier rubyid_default'>default</span>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_private'>private</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
      <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>

    <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
      <span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
      <span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>, </span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
      <span class='kw'>end</span>

    <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
    <span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Array</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>include?</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Proc</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>else</span> <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="short=-instance_method"></span>
      <div class="method_details ">
  <h3 class="signature " id="short-instance_method">
  
    #<strong>short</strong>  &#x21d2; <tt>String</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns The short form (i.e.: <code>-h</code>) for this option.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The short form (i.e.: <code>-h</code>) for this option.</p>
</div>
      
    </li>
  
</ul>

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


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>

<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Option (class)">Option</a></span></span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:short</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:long</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:type</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:required</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:default</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:meta</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:help</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:value</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:action</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:validator</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:parent</span>

  <span class='comment'># Creates a new option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param name [String] The name of this option. Must be unique.
</span>  <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
</span>  <span class='comment'># @param options [Hash] The settings for this option.
</span>  <span class='comment'># @param action [Proc] The action of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_forms'>forms</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
    <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the short form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@short</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@long</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option. Can be a Object, an Array, a Regexp or a Proc which takes one argument and returns a boolean.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The validator of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
    <span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the short form with a dash prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with a dash prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_short'>complete_short</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>-</span><span class='embexpr_beg'>#{</span><span class='ivar'>@short</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the long form with two dashes prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with two dashes prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_long'>complete_long</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>--</span><span class='embexpr_beg'>#{</span><span class='ivar'>@long</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns a label for this option, combining short and long forms.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] A label for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_label'>label</span>
    <span class='lbracket'>[</span><span class='id identifier rubyid_complete_short'>complete_short</span><span class='comma'>,</span> <span class='id identifier rubyid_complete_long'>complete_long</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the meta argument for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
</span>  <span class='comment'>#   if this option doesn&#39;t require a meta argument.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current default value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The default value for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
    <span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Bovem.html#OPTION_TYPES-constant" title="Bovem::OPTION_TYPES (constant)">OPTION_TYPES</a></span></span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if the current option has a default value.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] If the current option has a default value.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
    <span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the value of this option and also make sure that it is validated.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [Object] The new value of this option.
</span>  <span class='comment'># @param raise_error [Boolean] If raise an ArgumentError in case of validation errors.
</span>  <span class='comment'># @return [Boolean] `true` if operation succeeded, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_raise_error'>raise_error</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>

    <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='kw'>else</span> <span class='comment'># Validation failed
</span>      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='kw'>nil</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
      <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_raise_error'>raise_error</span>
      <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># Executes the action associated to this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Checks if this option requires an argument.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option requires an argument, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='lbracket'>[</span><span class='const'>String</span><span class='comma'>,</span> <span class='const'>Integer</span><span class='comma'>,</span> <span class='const'>Float</span><span class='comma'>,</span> <span class='const'>Array</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@type</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
  <span class='kw'>end</span>

  <span class='comment'># If this option was provided.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option was provided, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_provided?'>provided?</span>
    <span class='ivar'>@provided</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if this command has a help.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
    <span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The current value of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span>
    <span class='id identifier rubyid_provided?'>provided?</span> <span class='op'>?</span> <span class='ivar'>@value</span> <span class='op'>:</span> <span class='id identifier rubyid_default'>default</span>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_private'>private</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
      <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>

    <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
      <span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
      <span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>, </span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
      <span class='kw'>end</span>

    <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
    <span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Array</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>include?</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Proc</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>else</span> <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="type=-instance_method"></span>
      <div class="method_details ">
  <h3 class="signature " id="type-instance_method">
  
    #<strong>type</strong>  &#x21d2; <tt>Class</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns The type of this option.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Class</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The type of this option.</p>
</div>
      
    </li>
  
</ul>

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


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>

<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Option (class)">Option</a></span></span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:short</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:long</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:type</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:required</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:default</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:meta</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:help</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:value</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:action</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:validator</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:parent</span>

  <span class='comment'># Creates a new option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param name [String] The name of this option. Must be unique.
</span>  <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
</span>  <span class='comment'># @param options [Hash] The settings for this option.
</span>  <span class='comment'># @param action [Proc] The action of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_forms'>forms</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
    <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the short form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@short</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@long</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option. Can be a Object, an Array, a Regexp or a Proc which takes one argument and returns a boolean.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The validator of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
    <span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the short form with a dash prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with a dash prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_short'>complete_short</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>-</span><span class='embexpr_beg'>#{</span><span class='ivar'>@short</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the long form with two dashes prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with two dashes prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_long'>complete_long</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>--</span><span class='embexpr_beg'>#{</span><span class='ivar'>@long</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns a label for this option, combining short and long forms.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] A label for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_label'>label</span>
    <span class='lbracket'>[</span><span class='id identifier rubyid_complete_short'>complete_short</span><span class='comma'>,</span> <span class='id identifier rubyid_complete_long'>complete_long</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the meta argument for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
</span>  <span class='comment'>#   if this option doesn&#39;t require a meta argument.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current default value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The default value for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
    <span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Bovem.html#OPTION_TYPES-constant" title="Bovem::OPTION_TYPES (constant)">OPTION_TYPES</a></span></span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if the current option has a default value.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] If the current option has a default value.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
    <span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the value of this option and also make sure that it is validated.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [Object] The new value of this option.
</span>  <span class='comment'># @param raise_error [Boolean] If raise an ArgumentError in case of validation errors.
</span>  <span class='comment'># @return [Boolean] `true` if operation succeeded, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_raise_error'>raise_error</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>

    <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='kw'>else</span> <span class='comment'># Validation failed
</span>      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='kw'>nil</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
      <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_raise_error'>raise_error</span>
      <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># Executes the action associated to this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Checks if this option requires an argument.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option requires an argument, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='lbracket'>[</span><span class='const'>String</span><span class='comma'>,</span> <span class='const'>Integer</span><span class='comma'>,</span> <span class='const'>Float</span><span class='comma'>,</span> <span class='const'>Array</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@type</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
  <span class='kw'>end</span>

  <span class='comment'># If this option was provided.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option was provided, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_provided?'>provided?</span>
    <span class='ivar'>@provided</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if this command has a help.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
    <span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The current value of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span>
    <span class='id identifier rubyid_provided?'>provided?</span> <span class='op'>?</span> <span class='ivar'>@value</span> <span class='op'>:</span> <span class='id identifier rubyid_default'>default</span>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_private'>private</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
      <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>

    <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
      <span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
      <span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>, </span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
      <span class='kw'>end</span>

    <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
    <span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Array</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>include?</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Proc</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>else</span> <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="validator=-instance_method"></span>
      <div class="method_details ">
  <h3 class="signature " id="validator-instance_method">
  
    #<strong>validator</strong>  &#x21d2; <tt>Array|Regexp</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns or A constraint for valid values. Can be an Array of valid values or a Regexp.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Array|Regexp</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>or A constraint for valid values. Can be an Array of valid values or a Regexp.</p>
</div>
      
    </li>
  
</ul>

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


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>

<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Option (class)">Option</a></span></span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:short</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:long</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:type</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:required</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:default</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:meta</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:help</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:value</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:action</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:validator</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:parent</span>

  <span class='comment'># Creates a new option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param name [String] The name of this option. Must be unique.
</span>  <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
</span>  <span class='comment'># @param options [Hash] The settings for this option.
</span>  <span class='comment'># @param action [Proc] The action of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_forms'>forms</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
    <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the short form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@short</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@long</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option. Can be a Object, an Array, a Regexp or a Proc which takes one argument and returns a boolean.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The validator of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
    <span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the short form with a dash prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with a dash prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_short'>complete_short</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>-</span><span class='embexpr_beg'>#{</span><span class='ivar'>@short</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the long form with two dashes prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with two dashes prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_long'>complete_long</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>--</span><span class='embexpr_beg'>#{</span><span class='ivar'>@long</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns a label for this option, combining short and long forms.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] A label for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_label'>label</span>
    <span class='lbracket'>[</span><span class='id identifier rubyid_complete_short'>complete_short</span><span class='comma'>,</span> <span class='id identifier rubyid_complete_long'>complete_long</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the meta argument for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
</span>  <span class='comment'>#   if this option doesn&#39;t require a meta argument.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current default value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The default value for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
    <span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Bovem.html#OPTION_TYPES-constant" title="Bovem::OPTION_TYPES (constant)">OPTION_TYPES</a></span></span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if the current option has a default value.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] If the current option has a default value.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
    <span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the value of this option and also make sure that it is validated.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [Object] The new value of this option.
</span>  <span class='comment'># @param raise_error [Boolean] If raise an ArgumentError in case of validation errors.
</span>  <span class='comment'># @return [Boolean] `true` if operation succeeded, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_raise_error'>raise_error</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>

    <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='kw'>else</span> <span class='comment'># Validation failed
</span>      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='kw'>nil</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
      <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_raise_error'>raise_error</span>
      <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># Executes the action associated to this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Checks if this option requires an argument.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option requires an argument, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='lbracket'>[</span><span class='const'>String</span><span class='comma'>,</span> <span class='const'>Integer</span><span class='comma'>,</span> <span class='const'>Float</span><span class='comma'>,</span> <span class='const'>Array</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@type</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
  <span class='kw'>end</span>

  <span class='comment'># If this option was provided.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option was provided, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_provided?'>provided?</span>
    <span class='ivar'>@provided</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if this command has a help.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
    <span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The current value of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span>
    <span class='id identifier rubyid_provided?'>provided?</span> <span class='op'>?</span> <span class='ivar'>@value</span> <span class='op'>:</span> <span class='id identifier rubyid_default'>default</span>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_private'>private</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
      <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>

    <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
      <span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
      <span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>, </span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
      <span class='kw'>end</span>

    <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
    <span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Array</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>include?</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Proc</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>else</span> <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="value=-instance_method"></span>
      <div class="method_details ">
  <h3 class="signature " id="value-instance_method">
  
    #<strong>value</strong>  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Get the current value for this option.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Object</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The current value of this option.</p>
</div>
      
    </li>
  
</ul>

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


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 41</span>

<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Option (class)">Option</a></span></span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:name</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:short</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:long</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:type</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:required</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:default</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:meta</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:help</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:value</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:action</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:validator</span>
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:parent</span>

  <span class='comment'># Creates a new option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param name [String] The name of this option. Must be unique.
</span>  <span class='comment'># @param forms [Array] An array of short and long forms for this option. Missing forms will be inferred by the name.
</span>  <span class='comment'># @param options [Hash] The settings for this option.
</span>  <span class='comment'># @param action [Proc] The action of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_forms'>forms</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
    <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the short form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_short='>short=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}([a-z0-9])(.*)$</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@short</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The short form of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_long='>long=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='ivar'>@name</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>

    <span class='comment'># Clean value
</span>    <span class='id identifier rubyid_final_value'>final_value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-{0,2}(.+)$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>

    <span class='ivar'>@long</span> <span class='op'>=</span> <span class='id identifier rubyid_final_value'>final_value</span> <span class='kw'>if</span> <span class='id identifier rubyid_final_value'>final_value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the long form of this option. Can be a Object, an Array, a Regexp or a Proc which takes one argument and returns a boolean.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [String] The validator of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_validator='>validator=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Proc</span><span class='rparen'>)</span>
    <span class='ivar'>@validator</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the short form with a dash prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with a dash prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_short'>complete_short</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>-</span><span class='embexpr_beg'>#{</span><span class='ivar'>@short</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the long form with two dashes prepended.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] The short form with two dashes prepended.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_complete_long'>complete_long</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>--</span><span class='embexpr_beg'>#{</span><span class='ivar'>@long</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>

  <span class='comment'># Returns a label for this option, combining short and long forms.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String] A label for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_label'>label</span>
    <span class='lbracket'>[</span><span class='id identifier rubyid_complete_short'>complete_short</span><span class='comma'>,</span> <span class='id identifier rubyid_complete_long'>complete_long</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Returns the meta argument for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [String|NilClass] Returns the current meta argument for this option (the default value is the option name uppercased) or `nil`,
</span>  <span class='comment'>#   if this option doesn&#39;t require a meta argument.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='ivar'>@meta</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='ivar'>@meta</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current default value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The default value for this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default'>default</span>
    <span class='ivar'>@default</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Bovem.html#OPTION_TYPES-constant" title="Bovem::OPTION_TYPES (constant)">OPTION_TYPES</a></span></span><span class='lbracket'>[</span><span class='ivar'>@type</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if the current option has a default value.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] If the current option has a default value.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
    <span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
  <span class='kw'>end</span>

  <span class='comment'># Sets the value of this option and also make sure that it is validated.
</span>  <span class='comment'>#
</span>  <span class='comment'># @param value [Object] The new value of this option.
</span>  <span class='comment'># @param raise_error [Boolean] If raise an ArgumentError in case of validation errors.
</span>  <span class='comment'># @return [Boolean] `true` if operation succeeded, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_raise_error'>raise_error</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>

    <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='kw'>else</span> <span class='comment'># Validation failed
</span>      <span class='ivar'>@value</span> <span class='op'>=</span> <span class='kw'>nil</span>
      <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
      <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_raise_error'>raise_error</span>
      <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># Executes the action associated to this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
    <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
    <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># Checks if this option requires an argument.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option requires an argument, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
    <span class='lbracket'>[</span><span class='const'>String</span><span class='comma'>,</span> <span class='const'>Integer</span><span class='comma'>,</span> <span class='const'>Float</span><span class='comma'>,</span> <span class='const'>Array</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@type</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
  <span class='kw'>end</span>

  <span class='comment'># If this option was provided.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this option was provided, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_provided?'>provided?</span>
    <span class='ivar'>@provided</span>
  <span class='kw'>end</span>

  <span class='comment'># Check if this command has a help.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Boolean] `true` if this command has a help, `false` otherwise.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
    <span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the current value for this option.
</span>  <span class='comment'>#
</span>  <span class='comment'># @return [Object] The current value of this option.
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span>
    <span class='id identifier rubyid_provided?'>provided?</span> <span class='op'>?</span> <span class='ivar'>@value</span> <span class='op'>:</span> <span class='id identifier rubyid_default'>default</span>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_private'>private</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_forms'>setup_forms</span><span class='lparen'>(</span><span class='id identifier rubyid_forms'>forms</span><span class='rparen'>)</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_short'>short</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_long'>long</span> <span class='op'>=</span> <span class='id identifier rubyid_forms'>forms</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>2</span> <span class='op'>?</span> <span class='id identifier rubyid_forms'>forms</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='ivar'>@name</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_options'>setup_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
    <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_option'>option</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
      <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_setup_action'>setup_action</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
    <span class='ivar'>@action</span> <span class='op'>=</span> <span class='id identifier rubyid_action'>action</span> <span class='kw'>if</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:arity</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>2</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='ivar'>@parent</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span>

    <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span>
      <span class='kw'>case</span> <span class='id identifier rubyid_vs'>vs</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_regexp'>invalid_for_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rparen'>)</span>
      <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_for_proc'>invalid_for_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='rparen'>)</span>
      <span class='kw'>else</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_invalid_value'>invalid_value</span><span class='lparen'>(</span><span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_smart_join'>smart_join</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='comma'>,</span> <span class='label'>separator:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>, </span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>last_separator:</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_join_separator'>join_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_html_safe'>html_safe</span><span class='rparen'>)</span>
      <span class='kw'>end</span>

    <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:validation_failed</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># :nodoc:
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='id identifier rubyid_validator'>validator</span><span class='rparen'>)</span>
    <span class='kw'>case</span> <span class='id identifier rubyid_validator'>validator</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Array</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>include?</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Regexp</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>match</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Proc</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>call</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>else</span> <span class='kw'>false</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="complete_long-instance_method">
  
    #<strong>complete_long</strong>  &#x21d2; <tt>String</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns the long form with two dashes prepended.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The short form with two dashes prepended.</p>
</div>
      
    </li>
  
</ul>

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


112
113
114</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 112</span>

<span class='kw'>def</span> <span class='id identifier rubyid_complete_long'>complete_long</span>
  <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>--</span><span class='embexpr_beg'>#{</span><span class='ivar'>@long</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="complete_short-instance_method">
  
    #<strong>complete_short</strong>  &#x21d2; <tt>String</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns the short form with a dash prepended.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The short form with a dash prepended.</p>
</div>
      
    </li>
  
</ul>

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


105
106
107</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 105</span>

<span class='kw'>def</span> <span class='id identifier rubyid_complete_short'>complete_short</span>
  <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>-</span><span class='embexpr_beg'>#{</span><span class='ivar'>@short</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="default?-instance_method">
  
    #<strong>default?</strong>  &#x21d2; <tt>Boolean</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Check if the current option has a default value.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>If the current option has a default value.</p>
</div>
      
    </li>
  
</ul>

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


142
143
144</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 142</span>

<span class='kw'>def</span> <span class='id identifier rubyid_default?'>default?</span>
  <span class='op'>!</span><span class='ivar'>@default</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="execute_action-instance_method">
  
    #<strong>execute_action</strong>  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Executes the action associated to this option.</p>


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

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


167
168
169
170
171</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 167</span>

<span class='kw'>def</span> <span class='id identifier rubyid_execute_action'>execute_action</span>
  <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
  <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
  <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="help?-instance_method">
  
    #<strong>help?</strong>  &#x21d2; <tt>Boolean</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Check if this command has a help.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p><code>true</code> if this command has a help, <code>false</code> otherwise.</p>
</div>
      
    </li>
  
</ul>

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


190
191
192</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 190</span>

<span class='kw'>def</span> <span class='id identifier rubyid_help?'>help?</span>
  <span class='ivar'>@help</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="label-instance_method">
  
    #<strong>label</strong>  &#x21d2; <tt>String</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns a label for this option, combining short and long forms.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>A label for this option.</p>
</div>
      
    </li>
  
</ul>

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


119
120
121</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 119</span>

<span class='kw'>def</span> <span class='id identifier rubyid_label'>label</span>
  <span class='lbracket'>[</span><span class='id identifier rubyid_complete_short'>complete_short</span><span class='comma'>,</span> <span class='id identifier rubyid_complete_long'>complete_long</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="provided?-instance_method">
  
    #<strong>provided?</strong>  &#x21d2; <tt>Boolean</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>If this option was provided.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p><code>true</code> if this option was provided, <code>false</code> otherwise.</p>
</div>
      
    </li>
  
</ul>

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


183
184
185</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 183</span>

<span class='kw'>def</span> <span class='id identifier rubyid_provided?'>provided?</span>
  <span class='ivar'>@provided</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="requires_argument?-instance_method">
  
    #<strong>requires_argument?</strong>  &#x21d2; <tt>Boolean</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Checks if this option requires an argument.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p><code>true</code> if this option requires an argument, <code>false</code> otherwise.</p>
</div>
      
    </li>
  
</ul>

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


176
177
178</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 176</span>

<span class='kw'>def</span> <span class='id identifier rubyid_requires_argument?'>requires_argument?</span>
  <span class='lbracket'>[</span><span class='const'>String</span><span class='comma'>,</span> <span class='const'>Integer</span><span class='comma'>,</span> <span class='const'>Float</span><span class='comma'>,</span> <span class='const'>Array</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@type</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@action</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="set-instance_method">
  
    #<strong>set</strong>(value, raise_error = true)  &#x21d2; <tt>Boolean</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Sets the value of this option and also make sure that it is validated.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>value</span>
      
      
        <span class='type'>(<tt>Object</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The new value of this option.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>raise_error</span>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>true</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>If raise an ArgumentError in case of validation errors.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p><code>true</code> if operation succeeded, <code>false</code> otherwise.</p>
</div>
      
    </li>
  
</ul>

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


151
152
153
154
155
156
157
158
159
160
161
162
163
164</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/option.rb', line 151</span>

<span class='kw'>def</span> <span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_raise_error'>raise_error</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_vs'>vs</span> <span class='op'>=</span> <span class='id identifier rubyid_get_validator_method'>get_validator_method</span><span class='lparen'>(</span><span class='ivar'>@validator</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_vs'>vs</span> <span class='op'>?</span> <span class='ivar'>@validator</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>true</span>

  <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
    <span class='ivar'>@value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>true</span>
  <span class='kw'>else</span> <span class='comment'># Validation failed
</span>    <span class='ivar'>@value</span> <span class='op'>=</span> <span class='kw'>nil</span>
    <span class='ivar'>@provided</span> <span class='op'>=</span> <span class='kw'>false</span>
    <span class='id identifier rubyid_handle_set_failure'>handle_set_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_vs'>vs</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_raise_error'>raise_error</span>
    <span class='kw'>false</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:59 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>