kdict 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +7 -0
  5. data/.yardopts +3 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +6 -0
  8. data/Gemfile.lock +43 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +301 -0
  11. data/Rakefile +8 -0
  12. data/bin/console +14 -0
  13. data/bin/setup +8 -0
  14. data/docs/Between.html +302 -0
  15. data/docs/Bool.html +121 -0
  16. data/docs/Example1.md +195 -0
  17. data/docs/FalseClass.html +143 -0
  18. data/docs/KDict/Error.html +135 -0
  19. data/docs/KDict.html +128 -0
  20. data/docs/Kdict/Error.html +135 -0
  21. data/docs/Kdict.html +157 -0
  22. data/docs/Kdict_.html +143 -0
  23. data/docs/KwargDict.html +697 -0
  24. data/docs/KwargModel.html +638 -0
  25. data/docs/KwargTypes.html +988 -0
  26. data/docs/Numeric.html +148 -0
  27. data/docs/TrueClass.html +143 -0
  28. data/docs/_index.html +184 -0
  29. data/docs/class_list.html +51 -0
  30. data/docs/css/common.css +1 -0
  31. data/docs/css/full_list.css +58 -0
  32. data/docs/css/style.css +496 -0
  33. data/docs/file.Example1.html +240 -0
  34. data/docs/file.README.html +370 -0
  35. data/docs/file_list.html +61 -0
  36. data/docs/frames.html +17 -0
  37. data/docs/index.html +370 -0
  38. data/docs/js/app.js +303 -0
  39. data/docs/js/full_list.js +216 -0
  40. data/docs/js/jquery.js +4 -0
  41. data/docs/method_list.html +187 -0
  42. data/docs/top-level-namespace.html +112 -0
  43. data/examples/example1.rb +90 -0
  44. data/kdict.gemspec +39 -0
  45. data/lib/kdict/kwargdict/kwargtypes/bool.rb +9 -0
  46. data/lib/kdict/kwargdict/kwargtypes.rb +196 -0
  47. data/lib/kdict/kwargdict.rb +75 -0
  48. data/lib/kdict/kwargmodel.rb +40 -0
  49. data/lib/kdict/version.rb +5 -0
  50. data/lib/kdict.rb +19 -0
  51. data/ndoc/checksums +6 -0
  52. data/ndoc/complete +0 -0
  53. data/ndoc/object_types +0 -0
  54. data/ndoc/objects/root.dat +0 -0
  55. data/ndoc/proxy_types +0 -0
  56. metadata +150 -0
@@ -0,0 +1,697 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: KwargDict
8
+
9
+ &mdash; Documentation by YARD 0.9.19
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "KwargDict";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index (K)</a> &raquo;
40
+
41
+
42
+ <span class="title">KwargDict</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: KwargDict
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Hash</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">Hash</li>
78
+
79
+ <li class="next">KwargDict</li>
80
+
81
+ </ul>
82
+ <a href="#" class="inheritanceTree">show all</a>
83
+
84
+ </dd>
85
+ </dl>
86
+
87
+
88
+
89
+
90
+
91
+
92
+ <dl>
93
+ <dt>Includes:</dt>
94
+ <dd><span class='object_link'><a href="KwargTypes.html" title="KwargTypes (module)">KwargTypes</a></span></dd>
95
+ </dl>
96
+
97
+
98
+
99
+
100
+
101
+
102
+ <dl>
103
+ <dt>Defined in:</dt>
104
+ <dd>lib/kdict/kwargdict.rb</dd>
105
+ </dl>
106
+
107
+ </div>
108
+
109
+ <h2>Overview</h2><div class="docstring">
110
+ <div class="discussion">
111
+
112
+ <p>Creates a dictionary of generic, keyword-argument models. Allows user to validate a keyword and value against the models added to the dictionary.</p>
113
+
114
+ <p>Be sure to check out <span class='object_link'><a href="KwargTypes.html" title="KwargTypes (module)">KwargTypes</a></span> for a better understanding of what kind of models can be built and added to the dictionary.</p>
115
+
116
+
117
+ </div>
118
+ </div>
119
+ <div class="tags">
120
+
121
+
122
+ </div>
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+ <h2>
131
+ Instance Method Summary
132
+ <small><a href="#" class="summary_toggle">collapse</a></small>
133
+ </h2>
134
+
135
+ <ul class="summary">
136
+
137
+ <li class="public ">
138
+ <span class="summary_signature">
139
+
140
+ <a href="#[]=-instance_method" title="#[]= (instance method)">#<strong>[]=</strong>(kword, type_struct_prc) &#x21d2; KwargModel.new(type, struct, prc) </a>
141
+
142
+
143
+
144
+ </span>
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+ <span class="summary_desc"><div class='inline'>
155
+ <p>Adds a new keyword-KwargModel to self.</p>
156
+ </div></span>
157
+
158
+ </li>
159
+
160
+
161
+ <li class="public ">
162
+ <span class="summary_signature">
163
+
164
+ <a href="#add-instance_method" title="#add (instance method)">#<strong>add</strong>(*kwargmodel_list) &#x21d2; KwargModel.new(type, struct, prc) </a>
165
+
166
+
167
+
168
+ </span>
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+ <span class="summary_desc"><div class='inline'>
179
+ <p>Can add multiple KwargModels in the form of arrays.</p>
180
+ </div></span>
181
+
182
+ </li>
183
+
184
+
185
+ <li class="public ">
186
+ <span class="summary_signature">
187
+
188
+ <a href="#check-instance_method" title="#check (instance method)">#<strong>check</strong>(kword, arg) &#x21d2; Boolean </a>
189
+
190
+
191
+
192
+ </span>
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+ <span class="summary_desc"><div class='inline'>
203
+ <p>Checks a kword and arg passed to it against the list of KwargModels added to self.</p>
204
+ </div></span>
205
+
206
+ </li>
207
+
208
+
209
+ <li class="public ">
210
+ <span class="summary_signature">
211
+
212
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong> &#x21d2; KwargDict </a>
213
+
214
+
215
+
216
+ </span>
217
+
218
+
219
+ <span class="note title constructor">constructor</span>
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+ <span class="summary_desc"><div class='inline'>
229
+ <p>A new instance of KwargDict.</p>
230
+ </div></span>
231
+
232
+ </li>
233
+
234
+
235
+ </ul>
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="KwargTypes.html" title="KwargTypes (module)">KwargTypes</a></span></h3>
248
+ <p class="inherited"><span class='object_link'><a href="KwargTypes.html#adv_formof-instance_method" title="KwargTypes#adv_formof (method)">#adv_formof</a></span>, <span class='object_link'><a href="KwargTypes.html#and_kwargsof-instance_method" title="KwargTypes#and_kwargsof (method)">#and_kwargsof</a></span>, <span class='object_link'><a href="KwargTypes.html#anyNof-instance_method" title="KwargTypes#anyNof (method)">#anyNof</a></span>, <span class='object_link'><a href="KwargTypes.html#anyof-instance_method" title="KwargTypes#anyof (method)">#anyof</a></span>, <span class='object_link'><a href="KwargTypes.html#arrayof-instance_method" title="KwargTypes#arrayof (method)">#arrayof</a></span>, <span class='object_link'><a href="KwargTypes.html#formof-instance_method" title="KwargTypes#formof (method)">#formof</a></span>, <span class='object_link'><a href="KwargTypes.html#kwargsof-instance_method" title="KwargTypes#kwargsof (method)">#kwargsof</a></span>, <span class='object_link'><a href="KwargTypes.html#typeof-instance_method" title="KwargTypes#typeof (method)">#typeof</a></span></p>
249
+
250
+ <div id="constructor_details" class="method_details_list">
251
+ <h2>Constructor Details</h2>
252
+
253
+ <div class="method_details first">
254
+ <h3 class="signature first" id="initialize-instance_method">
255
+
256
+ #<strong>initialize</strong> &#x21d2; <tt><span class='object_link'><a href="" title="KwargDict (class)">KwargDict</a></span></tt>
257
+
258
+
259
+
260
+
261
+
262
+ </h3><div class="docstring">
263
+ <div class="discussion">
264
+
265
+ <p>Returns a new instance of KwargDict</p>
266
+
267
+
268
+ </div>
269
+ </div>
270
+ <div class="tags">
271
+
272
+ <div class="examples">
273
+ <p class="tag_title">Examples:</p>
274
+
275
+
276
+ <p class="example_title"><div class='inline'>
277
+ <p>Instantiating</p>
278
+ </div></p>
279
+
280
+ <pre class="example code"><code><span class='id identifier rubyid_my_dict'>my_dict</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="KwargDict (class)">KwargDict</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span></code></pre>
281
+
282
+ </div>
283
+
284
+
285
+ </div><table class="source_code">
286
+ <tr>
287
+ <td>
288
+ <pre class="lines">
289
+
290
+
291
+ 13
292
+ 14
293
+ 15</pre>
294
+ </td>
295
+ <td>
296
+ <pre class="code"><span class="info file"># File 'lib/kdict/kwargdict.rb', line 13</span>
297
+
298
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
299
+ <span class='kw'>super</span>
300
+ <span class='kw'>end</span></pre>
301
+ </td>
302
+ </tr>
303
+ </table>
304
+ </div>
305
+
306
+ </div>
307
+
308
+
309
+ <div id="instance_method_details" class="method_details_list">
310
+ <h2>Instance Method Details</h2>
311
+
312
+
313
+ <div class="method_details first">
314
+ <h3 class="signature first" id="[]=-instance_method">
315
+
316
+ #<strong>[]=</strong>(kword, type_struct_prc) &#x21d2; <tt><span class='object_link'><a href="KwargModel.html" title="KwargModel (class)">KwargModel</a></span>.new(type, struct, prc)</tt>
317
+
318
+
319
+
320
+
321
+
322
+ </h3><div class="docstring">
323
+ <div class="discussion">
324
+
325
+ <p>Adds a new keyword-KwargModel to self.</p>
326
+
327
+
328
+ </div>
329
+ </div>
330
+ <div class="tags">
331
+
332
+ <div class="examples">
333
+ <p class="tag_title">Examples:</p>
334
+
335
+
336
+ <p class="example_title"><div class='inline'>
337
+ <p>Adding a KwargModel to the KwargDict instance:</p>
338
+ </div></p>
339
+
340
+ <pre class="example code"><code><span class='id identifier rubyid_my_dict'>my_dict</span><span class='lbracket'>[</span><span class='symbol'>:example</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='symbol'>:arrayof</span><span class='comma'>,</span> <span class='const'>Integer</span>
341
+ <span class='id identifier rubyid_my_dict'>my_dict</span><span class='lbracket'>[</span><span class='symbol'>:proc_example</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='symbol'>:formof</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='const'>Float</span><span class='comma'>,</span> <span class='const'>Float</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='id identifier rubyid_n'>n</span> <span class='op'>&gt;</span> <span class='float'>2.5</span> <span class='rbrace'>}</span>
342
+ <span class='id identifier rubyid_p'>p</span> <span class='id identifier rubyid_my_dict'>my_dict</span><span class='lbracket'>[</span><span class='symbol'>:example</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_splay'>splay</span> <span class='comment'>#=&gt; [:arrayof, Integer]
343
+ </span><span class='id identifier rubyid_p'>p</span> <span class='id identifier rubyid_my_dict'>my_dict</span><span class='lbracket'>[</span><span class='symbol'>:proc_example</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_splay'>splay</span> <span class='comment'>#=&gt; [:formof, [Float, Float], &lt;Proc:0x000055b98848a6d8@kwargdict.rb:20&gt;] </span></code></pre>
344
+
345
+ </div>
346
+ <p class="tag_title">Parameters:</p>
347
+ <ul class="param">
348
+
349
+ <li>
350
+
351
+ <span class='name'>kword</span>
352
+
353
+
354
+ <span class='type'></span>
355
+
356
+
357
+
358
+ &mdash;
359
+ <div class='inline'>
360
+ <p>The name of the kword.</p>
361
+ </div>
362
+
363
+ </li>
364
+
365
+ <li>
366
+
367
+ <span class='name'>type_struct_prc</span>
368
+
369
+
370
+ <span class='type'></span>
371
+
372
+
373
+
374
+ &mdash;
375
+ <div class='inline'>
376
+ <p>Collectively the <strong>typedef</strong>, <strong>struct</strong>, and optional <strong>prc</strong>.</p>
377
+ </div>
378
+
379
+ </li>
380
+
381
+ <li>
382
+
383
+ <span class='name'>type</span>
384
+
385
+
386
+ <span class='type'></span>
387
+
388
+
389
+
390
+ &mdash;
391
+ <div class='inline'>
392
+ <p>AKA the <strong>typedef</strong>, a symbolic form of anyone of the included methods from <span class='object_link'><a href="KwargTypes.html" title="KwargTypes (module)">KwargTypes</a></span></p>
393
+ </div>
394
+
395
+ </li>
396
+
397
+ <li>
398
+
399
+ <span class='name'>struct</span>
400
+
401
+
402
+ <span class='type'></span>
403
+
404
+
405
+
406
+ &mdash;
407
+ <div class='inline'>
408
+ <p>The <strong>typedef</strong> format is dependent upon the model&#39;s <strong>typedef</strong>. Be sure to refer to those <span class='object_link'><a href="KwargTypes.html" title="KwargTypes (module)">KwargTypes</a></span> to set <strong>structs</strong> appropriately.</p>
409
+ </div>
410
+
411
+ </li>
412
+
413
+ <li>
414
+
415
+ <span class='name'>prc</span>
416
+
417
+
418
+ <span class='type'></span>
419
+
420
+
421
+
422
+ &mdash;
423
+ <div class='inline'>
424
+ <p>Optional. A Proc that&#39;s meant to add to the specificity of <strong>struct</strong>. Not all <strong>typedefs</strong> accept Procs.</p>
425
+ </div>
426
+
427
+ </li>
428
+
429
+ </ul>
430
+
431
+ <p class="tag_title">Returns:</p>
432
+ <ul class="return">
433
+
434
+ <li>
435
+
436
+
437
+ <span class='type'>(<tt><span class='object_link'><a href="KwargModel.html" title="KwargModel (class)">KwargModel</a></span>.new(type, struct, prc)</tt>)</span>
438
+
439
+
440
+
441
+ </li>
442
+
443
+ </ul>
444
+
445
+ <p class="tag_title">See Also:</p>
446
+ <ul class="see">
447
+
448
+ <li><span class='object_link'><a href="KwargModel.html" title="KwargModel (class)">KwargModel</a></span></li>
449
+
450
+ </ul>
451
+
452
+ </div><table class="source_code">
453
+ <tr>
454
+ <td>
455
+ <pre class="lines">
456
+
457
+
458
+ 30
459
+ 31
460
+ 32
461
+ 33
462
+ 34</pre>
463
+ </td>
464
+ <td>
465
+ <pre class="code"><span class="info file"># File 'lib/kdict/kwargdict.rb', line 30</span>
466
+
467
+ <span class='kw'>def</span> <span class='op'>[]=</span><span class='lparen'>(</span><span class='id identifier rubyid_kword'>kword</span><span class='comma'>,</span> <span class='id identifier rubyid_type_struct_prc'>type_struct_prc</span><span class='rparen'>)</span>
468
+ <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_struct'>struct</span><span class='comma'>,</span> <span class='id identifier rubyid_prc'>prc</span> <span class='op'>=</span> <span class='id identifier rubyid_type_struct_prc'>type_struct_prc</span>
469
+ <span class='id identifier rubyid_typedef?'>typedef?</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='rparen'>)</span>
470
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_kword'>kword</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="KwargModel.html" title="KwargModel (class)">KwargModel</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="KwargModel.html#initialize-instance_method" title="KwargModel#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_struct'>struct</span><span class='comma'>,</span> <span class='id identifier rubyid_prc'>prc</span><span class='rparen'>)</span><span class='rparen'>)</span>
471
+ <span class='kw'>end</span></pre>
472
+ </td>
473
+ </tr>
474
+ </table>
475
+ </div>
476
+
477
+ <div class="method_details ">
478
+ <h3 class="signature " id="add-instance_method">
479
+
480
+ #<strong>add</strong>(*kwargmodel_list) &#x21d2; <tt><span class='object_link'><a href="KwargModel.html" title="KwargModel (class)">KwargModel</a></span>.new(type, struct, prc)</tt>
481
+
482
+
483
+
484
+
485
+
486
+ </h3><div class="docstring">
487
+ <div class="discussion">
488
+
489
+ <p>Can add multiple KwargModels in the form of arrays. Remember that <strong>prc</strong> is optional.</p>
490
+
491
+
492
+ </div>
493
+ </div>
494
+ <div class="tags">
495
+
496
+ <div class="examples">
497
+ <p class="tag_title">Examples:</p>
498
+
499
+
500
+ <p class="example_title"><div class='inline'>
501
+ <p>Adding a KwargModel:</p>
502
+ </div></p>
503
+
504
+ <pre class="example code"><code><span class='id identifier rubyid_my_dict'>my_dict</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='symbol'>:one</span><span class='comma'>,</span> <span class='symbol'>:typeof</span><span class='comma'>,</span> <span class='const'>String</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='symbol'>:two</span><span class='comma'>,</span> <span class='symbol'>:anyof</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>this</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>that</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='rparen'>)</span>
505
+ <span class='id identifier rubyid_p'>p</span> <span class='id identifier rubyid_my_dict'>my_dict</span><span class='lbracket'>[</span><span class='symbol'>:one</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_splay'>splay</span> <span class='comment'>#=&gt; [:typeof, String]
506
+ </span><span class='id identifier rubyid_p'>p</span> <span class='id identifier rubyid_my_dict'>my_dict</span><span class='lbracket'>[</span><span class='symbol'>:two</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_splay'>splay</span> <span class='comment'>#=&gt; [:anyof, [&#39;this&#39;, &#39;that&#39;]] </span></code></pre>
507
+
508
+ </div>
509
+ <p class="tag_title">Parameters:</p>
510
+ <ul class="param">
511
+
512
+ <li>
513
+
514
+ <span class='name'>kwargmodel_list</span>
515
+
516
+
517
+ <span class='type'></span>
518
+
519
+
520
+
521
+ &mdash;
522
+ <div class='inline'>
523
+ <p>A collection of arrays each in the form [<strong>kword</strong>, <strong>typedef</strong>, <strong>struct</strong>, <strong>prc</strong>].</p>
524
+ </div>
525
+
526
+ </li>
527
+
528
+ </ul>
529
+
530
+ <p class="tag_title">Returns:</p>
531
+ <ul class="return">
532
+
533
+ <li>
534
+
535
+
536
+ <span class='type'>(<tt><span class='object_link'><a href="KwargModel.html" title="KwargModel (class)">KwargModel</a></span>.new(type, struct, prc)</tt>)</span>
537
+
538
+
539
+
540
+ </li>
541
+
542
+ </ul>
543
+
544
+ <p class="tag_title">See Also:</p>
545
+ <ul class="see">
546
+
547
+ <li><span class='object_link'><a href="#[]=-instance_method" title="KwargDict#[]= (method)">#[]=</a></span></li>
548
+
549
+ </ul>
550
+
551
+ </div><table class="source_code">
552
+ <tr>
553
+ <td>
554
+ <pre class="lines">
555
+
556
+
557
+ 44
558
+ 45
559
+ 46
560
+ 47
561
+ 48</pre>
562
+ </td>
563
+ <td>
564
+ <pre class="code"><span class="info file"># File 'lib/kdict/kwargdict.rb', line 44</span>
565
+
566
+ <span class='kw'>def</span> <span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_kwargmodel_list'>kwargmodel_list</span><span class='rparen'>)</span>
567
+ <span class='id identifier rubyid_kwargmodel_list'>kwargmodel_list</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_kword'>kword</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_struct'>struct</span><span class='comma'>,</span> <span class='id identifier rubyid_prc'>prc</span><span class='op'>|</span>
568
+ <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_kword'>kword</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_struct'>struct</span><span class='comma'>,</span> <span class='id identifier rubyid_prc'>prc</span>
569
+ <span class='kw'>end</span>
570
+ <span class='kw'>end</span></pre>
571
+ </td>
572
+ </tr>
573
+ </table>
574
+ </div>
575
+
576
+ <div class="method_details ">
577
+ <h3 class="signature " id="check-instance_method">
578
+
579
+ #<strong>check</strong>(kword, arg) &#x21d2; <tt>Boolean</tt>
580
+
581
+
582
+
583
+
584
+
585
+ </h3><div class="docstring">
586
+ <div class="discussion">
587
+
588
+ <p>Checks a kword and arg passed to it against the list of KwargModels added to self. Returns false if the kword doesn&#39;t exist or if the arg passed in fails validation. If the KwargModel has a Proc, the proc call will also have to evaluate to true and does not replace or override the <strong>struct</strong>.</p>
589
+
590
+
591
+ </div>
592
+ </div>
593
+ <div class="tags">
594
+
595
+ <div class="examples">
596
+ <p class="tag_title">Examples:</p>
597
+
598
+
599
+ <p class="example_title"><div class='inline'>
600
+ <p>Adding a KwargModel and Checking User Input Against It:</p>
601
+ </div></p>
602
+
603
+ <pre class="example code"><code><span class='id identifier rubyid_my_dict'>my_dict</span><span class='lbracket'>[</span><span class='symbol'>:label</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='symbol'>:typeof</span><span class='comma'>,</span> <span class='const'>String</span>
604
+ <span class='id identifier rubyid_my_dict'>my_dict</span><span class='lbracket'>[</span><span class='symbol'>:rgba</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='symbol'>:formof</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='const'>Numeric</span><span class='rbracket'>]</span><span class='op'>*</span><span class='int'>4</span><span class='comma'>,</span> <span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='id identifier rubyid_n'>n</span><span class='period'>.</span><span class='id identifier rubyid_ibetween'>ibetween</span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
605
+ <span class='id identifier rubyid_my_dict'>my_dict</span><span class='period'>.</span><span class='id identifier rubyid_check'>check</span><span class='lparen'>(</span><span class='symbol'>:label</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Labels Are Fun!</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>#=&gt; true
606
+ </span><span class='id identifier rubyid_my_dict'>my_dict</span><span class='period'>.</span><span class='id identifier rubyid_check'>check</span><span class='lparen'>(</span><span class='symbol'>:label</span><span class='comma'>,</span> <span class='int'>45</span><span class='rparen'>)</span> <span class='comment'>#=&gt; false
607
+ </span><span class='id identifier rubyid_my_dict'>my_dict</span><span class='period'>.</span><span class='id identifier rubyid_check'>check</span><span class='lparen'>(</span><span class='symbol'>:rgba</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='float'>0.5</span><span class='comma'>,</span> <span class='int'>1</span><span class='comma'>,</span> <span class='float'>0.25</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='comment'>#=&gt; true
608
+ </span><span class='id identifier rubyid_my_dict'>my_dict</span><span class='period'>.</span><span class='id identifier rubyid_check'>check</span><span class='lparen'>(</span><span class='symbol'>:rgba</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='float'>0.5</span><span class='comma'>,</span> <span class='int'>1</span><span class='comma'>,</span> <span class='float'>0.25</span><span class='comma'>,</span> <span class='float'>11.5</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='comment'>#=&gt; false</span></code></pre>
609
+
610
+ </div>
611
+ <p class="tag_title">Parameters:</p>
612
+ <ul class="param">
613
+
614
+ <li>
615
+
616
+ <span class='name'>kword</span>
617
+
618
+
619
+ <span class='type'></span>
620
+
621
+
622
+
623
+ &mdash;
624
+ <div class='inline'>
625
+ <p>The keyword whose <strong>struct</strong> you wish to check arg against.</p>
626
+ </div>
627
+
628
+ </li>
629
+
630
+ <li>
631
+
632
+ <span class='name'>arg</span>
633
+
634
+
635
+ <span class='type'></span>
636
+
637
+
638
+
639
+ &mdash;
640
+ <div class='inline'>
641
+ <p>The argument, expression, etc., that you wish check against the <strong>struct</strong>.</p>
642
+ </div>
643
+
644
+ </li>
645
+
646
+ </ul>
647
+
648
+ <p class="tag_title">Returns:</p>
649
+ <ul class="return">
650
+
651
+ <li>
652
+
653
+
654
+ <span class='type'>(<tt>Boolean</tt>)</span>
655
+
656
+
657
+
658
+ </li>
659
+
660
+ </ul>
661
+
662
+ </div><table class="source_code">
663
+ <tr>
664
+ <td>
665
+ <pre class="lines">
666
+
667
+
668
+ 64
669
+ 65
670
+ 66
671
+ 67</pre>
672
+ </td>
673
+ <td>
674
+ <pre class="code"><span class="info file"># File 'lib/kdict/kwargdict.rb', line 64</span>
675
+
676
+ <span class='kw'>def</span> <span class='id identifier rubyid_check'>check</span><span class='lparen'>(</span><span class='id identifier rubyid_kword'>kword</span><span class='comma'>,</span> <span class='id identifier rubyid_arg'>arg</span><span class='rparen'>)</span>
677
+ <span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_kword'>kword</span><span class='rparen'>)</span>
678
+ <span class='id identifier rubyid_valid?'>valid?</span><span class='lparen'>(</span><span class='id identifier rubyid_arg'>arg</span><span class='comma'>,</span> <span class='op'>*</span><span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_kword'>kword</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_splay'>splay</span><span class='rparen'>)</span>
679
+ <span class='kw'>end</span></pre>
680
+ </td>
681
+ </tr>
682
+ </table>
683
+ </div>
684
+
685
+ </div>
686
+
687
+ </div>
688
+
689
+ <div id="footer">
690
+ Generated on Thu Apr 11 21:45:30 2019 by
691
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
692
+ 0.9.19 (ruby-2.6.2).
693
+ </div>
694
+
695
+ </div>
696
+ </body>
697
+ </html>