shenanigans 1.0.14 → 1.0.15

Sign up to get free protection for your applications and to get access to all the features.
data/doc/Hash.html DELETED
@@ -1,438 +0,0 @@
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: Hash
8
-
9
- &mdash; Documentation by YARD 0.9.24
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="css/style.css" type="text/css" />
14
-
15
- <link rel="stylesheet" href="css/common.css" type="text/css" />
16
-
17
- <script type="text/javascript">
18
- pathId = "Hash";
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 (H)</a> &raquo;
40
-
41
-
42
- <span class="title">Hash</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: Hash
63
-
64
-
65
-
66
- </h1>
67
- <div class="box_info">
68
-
69
- <dl>
70
- <dt>Inherits:</dt>
71
- <dd>
72
- <span class="inheritName"><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></span>
73
-
74
- <ul class="fullTree">
75
- <li><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></li>
76
-
77
- <li class="next">Hash</li>
78
-
79
- </ul>
80
- <a href="#" class="inheritanceTree">show all</a>
81
-
82
- </dd>
83
- </dl>
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
- <dl>
96
- <dt>Defined in:</dt>
97
- <dd>lib/shenanigans/hash/extract.rb<span class="defines">,<br />
98
- lib/shenanigans/hash/to_ostruct.rb,<br /> lib/shenanigans/hash/has_shape_pred.rb</span>
99
- </dd>
100
- </dl>
101
-
102
- </div>
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
- <h2>
113
- Instance Method Summary
114
- <small><a href="#" class="summary_toggle">collapse</a></small>
115
- </h2>
116
-
117
- <ul class="summary">
118
-
119
- <li class="public ">
120
- <span class="summary_signature">
121
-
122
- <a href="#extract-instance_method" title="#extract (instance method)">#<strong>extract</strong>(*ks) &#x21d2; Object </a>
123
-
124
-
125
-
126
- </span>
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
- <span class="summary_desc"><div class='inline'>
137
- <p>Returns a new hash only with the specified keys (if present).</p>
138
- </div></span>
139
-
140
- </li>
141
-
142
-
143
- <li class="public ">
144
- <span class="summary_signature">
145
-
146
- <a href="#has_shape%3F-instance_method" title="#has_shape? (instance method)">#<strong>has_shape?</strong>(shape) &#x21d2; Boolean </a>
147
-
148
-
149
-
150
- </span>
151
-
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
- <span class="summary_desc"><div class='inline'>
161
- <p>Checks if a hash has a certain structure.</p>
162
- </div></span>
163
-
164
- </li>
165
-
166
-
167
- <li class="public ">
168
- <span class="summary_signature">
169
-
170
- <a href="#to_ostruct-instance_method" title="#to_ostruct (instance method)">#<strong>to_ostruct</strong> &#x21d2; Object </a>
171
-
172
-
173
-
174
- </span>
175
-
176
-
177
-
178
-
179
-
180
-
181
-
182
-
183
-
184
- <span class="summary_desc"><div class='inline'>
185
- <p>Recursively converts a <code>Hash</code> and all nested <code>Hash</code>es to <code>OpenStruct</code>s.</p>
186
- </div></span>
187
-
188
- </li>
189
-
190
-
191
- </ul>
192
-
193
-
194
-
195
-
196
- <div id="instance_method_details" class="method_details_list">
197
- <h2>Instance Method Details</h2>
198
-
199
-
200
- <div class="method_details first">
201
- <h3 class="signature first" id="extract-instance_method">
202
-
203
- #<strong>extract</strong>(*ks) &#x21d2; <tt><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></tt>
204
-
205
-
206
-
207
-
208
-
209
- </h3><div class="docstring">
210
- <div class="discussion">
211
-
212
- <p>Returns a new hash only with the specified keys (if present).</p>
213
-
214
-
215
- </div>
216
- </div>
217
- <div class="tags">
218
-
219
- <div class="examples">
220
- <p class="tag_title">Examples:</p>
221
-
222
-
223
- <p class="example_title"><div class='inline'>
224
- <p>Key order does not matter</p>
225
- </div></p>
226
-
227
- <pre class="example code"><code><span class='id identifier rubyid_hash'>hash</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>a:</span> <span class='int'>1</span><span class='comma'>,</span> <span class='label'>b:</span> <span class='int'>2</span><span class='comma'>,</span> <span class='label'>c:</span> <span class='int'>3</span> <span class='rbrace'>}</span>
228
- <span class='id identifier rubyid_hash'>hash</span><span class='period'>.</span><span class='id identifier rubyid_extract'>extract</span><span class='lparen'>(</span><span class='symbol'>:b</span><span class='comma'>,</span> <span class='symbol'>:a</span><span class='rparen'>)</span> <span class='comment'>#=&gt; { a: 1, b: 2 }</span></code></pre>
229
-
230
-
231
- <p class="example_title"><div class='inline'>
232
- <p>Missing keys are ignored</p>
233
- </div></p>
234
-
235
- <pre class="example code"><code><span class='id identifier rubyid_hash'>hash</span><span class='period'>.</span><span class='id identifier rubyid_extract'>extract</span><span class='lparen'>(</span><span class='symbol'>:a</span><span class='comma'>,</span> <span class='symbol'>:d</span><span class='rparen'>)</span> <span class='comment'>#=&gt; { a: 1}</span></code></pre>
236
-
237
- </div>
238
-
239
-
240
- </div><table class="source_code">
241
- <tr>
242
- <td>
243
- <pre class="lines">
244
-
245
-
246
- 9
247
- 10
248
- 11
249
- 12</pre>
250
- </td>
251
- <td>
252
- <pre class="code"><span class="info file"># File 'lib/shenanigans/hash/extract.rb', line 9</span>
253
-
254
- <span class='kw'>def</span> <span class='id identifier rubyid_extract'>extract</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_ks'>ks</span><span class='rparen'>)</span>
255
- <span class='id identifier rubyid_existing'>existing</span> <span class='op'>=</span> <span class='id identifier rubyid_keys'>keys</span> <span class='op'>&amp;</span> <span class='id identifier rubyid_ks'>ks</span>
256
- <span class='const'><span class='object_link'><a href="" title="Hash (class)">Hash</a></span></span><span class='lbracket'>[</span><span class='id identifier rubyid_existing'>existing</span><span class='period'>.</span><span class='id identifier rubyid_zip'>zip</span><span class='lparen'>(</span><span class='id identifier rubyid_values_at'>values_at</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_existing'>existing</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='rbracket'>]</span>
257
- <span class='kw'>end</span></pre>
258
- </td>
259
- </tr>
260
- </table>
261
- </div>
262
-
263
- <div class="method_details ">
264
- <h3 class="signature " id="has_shape?-instance_method">
265
-
266
- #<strong>has_shape?</strong>(shape) &#x21d2; <tt>Boolean</tt>
267
-
268
-
269
-
270
-
271
-
272
- </h3><div class="docstring">
273
- <div class="discussion">
274
-
275
- <p>Checks if a hash has a certain structure.</p>
276
-
277
-
278
- </div>
279
- </div>
280
- <div class="tags">
281
-
282
- <div class="examples">
283
- <p class="tag_title">Examples:</p>
284
-
285
-
286
- <p class="example_title"><div class='inline'>
287
- <p>Simple hash</p>
288
- </div></p>
289
-
290
- <pre class="example code"><code><span class='id identifier rubyid_h'>h</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>k1:</span> <span class='int'>1</span><span class='comma'>,</span> <span class='label'>k2:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>1</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span>
291
- <span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_has_shape?'>has_shape?</span><span class='lparen'>(</span><span class='label'>k1:</span> <span class='const'>Fixnum</span><span class='comma'>,</span> <span class='label'>k2:</span> <span class='const'><span class='object_link'><a href="String.html" title="String (class)">String</a></span></span><span class='rparen'>)</span> <span class='comment'>#=&gt; true
292
- </span><span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_has_shape?'>has_shape?</span><span class='lparen'>(</span><span class='label'>k1:</span> <span class='const'>Class</span><span class='comma'>,</span> <span class='label'>k2:</span> <span class='const'><span class='object_link'><a href="String.html" title="String (class)">String</a></span></span><span class='rparen'>)</span> <span class='comment'>#=&gt; false</span></code></pre>
293
-
294
-
295
- <p class="example_title"><div class='inline'>
296
- <p>Nested hashes</p>
297
- </div></p>
298
-
299
- <pre class="example code"><code><span class='id identifier rubyid_h'>h</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>k1:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>k2:</span> <span class='lbrace'>{</span> <span class='label'>k3:</span> <span class='const'>Struct</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Foo</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
300
- <span class='id identifier rubyid_shape'>shape</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>k1:</span> <span class='const'><span class='object_link'><a href="Array.html" title="Array (class)">Array</a></span></span><span class='comma'>,</span> <span class='label'>k2:</span> <span class='lbrace'>{</span> <span class='label'>k3:</span> <span class='const'><span class='object_link'><a href="Module.html" title="Module (class)">Module</a></span></span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
301
- <span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_has_shape?'>has_shape?</span><span class='lparen'>(</span><span class='id identifier rubyid_shape'>shape</span><span class='rparen'>)</span> <span class='comment'>#=&gt; true</span></code></pre>
302
-
303
- </div>
304
-
305
- <p class="tag_title">Returns:</p>
306
- <ul class="return">
307
-
308
- <li>
309
-
310
-
311
- <span class='type'>(<tt>Boolean</tt>)</span>
312
-
313
-
314
-
315
- </li>
316
-
317
- </ul>
318
-
319
- </div><table class="source_code">
320
- <tr>
321
- <td>
322
- <pre class="lines">
323
-
324
-
325
- 12
326
- 13
327
- 14
328
- 15
329
- 16</pre>
330
- </td>
331
- <td>
332
- <pre class="code"><span class="info file"># File 'lib/shenanigans/hash/has_shape_pred.rb', line 12</span>
333
-
334
- <span class='kw'>def</span> <span class='id identifier rubyid_has_shape?'>has_shape?</span><span class='lparen'>(</span><span class='id identifier rubyid_shape'>shape</span><span class='rparen'>)</span>
335
- <span class='id identifier rubyid_all?'>all?</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span>
336
- <span class='const'><span class='object_link'><a href="" title="Hash (class)">Hash</a></span></span> <span class='op'>===</span> <span class='id identifier rubyid_v'>v</span> <span class='op'>?</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_has_shape?'>has_shape?</span><span class='lparen'>(</span><span class='id identifier rubyid_shape'>shape</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_shape'>shape</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>===</span> <span class='id identifier rubyid_v'>v</span>
337
- <span class='kw'>end</span>
338
- <span class='kw'>end</span></pre>
339
- </td>
340
- </tr>
341
- </table>
342
- </div>
343
-
344
- <div class="method_details ">
345
- <h3 class="signature " id="to_ostruct-instance_method">
346
-
347
- #<strong>to_ostruct</strong> &#x21d2; <tt><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></tt>
348
-
349
-
350
-
351
-
352
-
353
- </h3><div class="docstring">
354
- <div class="discussion">
355
-
356
- <p>Recursively converts a <code>Hash</code> and all nested <code>Hash</code>es to <code>OpenStruct</code>s. Especially useful for parsing YAML.</p>
357
-
358
-
359
- </div>
360
- </div>
361
- <div class="tags">
362
-
363
- <div class="examples">
364
- <p class="tag_title">Examples:</p>
365
-
366
-
367
- <pre class="example code"><code><span class='id identifier rubyid_yaml'>yaml</span><span class='op'>=</span><span class='heredoc_beg'>&lt;&lt;EOY</span>
368
- <span class='tstring_content'>subject: Programming Languages
369
- languages:
370
- - name : Ruby
371
- creator : Matz
372
- - name : Python
373
- creator : Guido van Rossum
374
- - name : Perl
375
- creator : Larry Wall
376
- </span><span class='heredoc_end'>EOY
377
- </span><span class='id identifier rubyid_struct'>struct</span> <span class='op'>=</span> <span class='const'>YAML</span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span><span class='lparen'>(</span><span class='id identifier rubyid_yaml'>yaml</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_ostruct'>to_ostruct</span>
378
- <span class='id identifier rubyid_struct'>struct</span><span class='period'>.</span><span class='id identifier rubyid_subject'>subject</span> <span class='comment'>#=&gt; &quot;Programming Languages&quot;
379
- </span><span class='id identifier rubyid_struct'>struct</span><span class='period'>.</span><span class='id identifier rubyid_languages'>languages</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='comment'>#=&gt; #&lt;OpenStruct name=&quot;Ruby&quot;, creator=&quot;Matz&quot;&gt;
380
- </span><span class='id identifier rubyid_struct'>struct</span><span class='period'>.</span><span class='id identifier rubyid_languages'>languages</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_creator'>creator</span> <span class='comment'>#=&gt; &quot;Matz&quot;</span></code></pre>
381
-
382
- </div>
383
-
384
-
385
- </div><table class="source_code">
386
- <tr>
387
- <td>
388
- <pre class="lines">
389
-
390
-
391
- 22
392
- 23
393
- 24
394
- 25
395
- 26
396
- 27
397
- 28
398
- 29
399
- 30
400
- 31
401
- 32
402
- 33
403
- 34</pre>
404
- </td>
405
- <td>
406
- <pre class="code"><span class="info file"># File 'lib/shenanigans/hash/to_ostruct.rb', line 22</span>
407
-
408
- <span class='kw'>def</span> <span class='id identifier rubyid_to_ostruct'>to_ostruct</span>
409
- <span class='id identifier rubyid_arr'>arr</span> <span class='op'>=</span> <span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span>
410
- <span class='kw'>case</span> <span class='id identifier rubyid_v'>v</span>
411
- <span class='kw'>when</span> <span class='const'><span class='object_link'><a href="" title="Hash (class)">Hash</a></span></span>
412
- <span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_to_ostruct'>to_ostruct</span><span class='rbracket'>]</span>
413
- <span class='kw'>when</span> <span class='const'><span class='object_link'><a href="Array.html" title="Array (class)">Array</a></span></span>
414
- <span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_el'>el</span><span class='op'>|</span> <span class='id identifier rubyid_el'>el</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:to_ostruct</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_el'>el</span><span class='period'>.</span><span class='id identifier rubyid_to_ostruct'>to_ostruct</span> <span class='op'>:</span> <span class='id identifier rubyid_el'>el</span> <span class='rbrace'>}</span><span class='rbracket'>]</span>
415
- <span class='kw'>else</span>
416
- <span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='rbracket'>]</span>
417
- <span class='kw'>end</span>
418
- <span class='rbrace'>}</span>
419
- <span class='const'>OpenStruct</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="" title="Hash (class)">Hash</a></span></span><span class='lbracket'>[</span><span class='id identifier rubyid_arr'>arr</span><span class='rbracket'>]</span><span class='rparen'>)</span>
420
- <span class='kw'>end</span></pre>
421
- </td>
422
- </tr>
423
- </table>
424
- </div>
425
-
426
- </div>
427
-
428
- </div>
429
-
430
- <div id="footer">
431
- Generated on Tue May 5 19:54:28 2020 by
432
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
433
- 0.9.24 (ruby-2.7.1).
434
- </div>
435
-
436
- </div>
437
- </body>
438
- </html>
data/doc/Integer.html DELETED
@@ -1,219 +0,0 @@
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: Integer
8
-
9
- &mdash; Documentation by YARD 0.9.24
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="css/style.css" type="text/css" />
14
-
15
- <link rel="stylesheet" href="css/common.css" type="text/css" />
16
-
17
- <script type="text/javascript">
18
- pathId = "Integer";
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 (I)</a> &raquo;
40
-
41
-
42
- <span class="title">Integer</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: Integer
63
-
64
-
65
-
66
- </h1>
67
- <div class="box_info">
68
-
69
- <dl>
70
- <dt>Inherits:</dt>
71
- <dd>
72
- <span class="inheritName"><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></span>
73
-
74
- <ul class="fullTree">
75
- <li><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></li>
76
-
77
- <li class="next">Integer</li>
78
-
79
- </ul>
80
- <a href="#" class="inheritanceTree">show all</a>
81
-
82
- </dd>
83
- </dl>
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
- <dl>
96
- <dt>Defined in:</dt>
97
- <dd>lib/shenanigans/integer/string_length.rb</dd>
98
- </dl>
99
-
100
- </div>
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
- <h2>
111
- Instance Method Summary
112
- <small><a href="#" class="summary_toggle">collapse</a></small>
113
- </h2>
114
-
115
- <ul class="summary">
116
-
117
- <li class="public ">
118
- <span class="summary_signature">
119
-
120
- <a href="#string_length-instance_method" title="#string_length (instance method)">#<strong>string_length</strong> &#x21d2; Object </a>
121
-
122
-
123
-
124
- </span>
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
- <span class="summary_desc"><div class='inline'>
135
- <p>Returns the length of the number&#39;s string representation.</p>
136
- </div></span>
137
-
138
- </li>
139
-
140
-
141
- </ul>
142
-
143
-
144
-
145
-
146
- <div id="instance_method_details" class="method_details_list">
147
- <h2>Instance Method Details</h2>
148
-
149
-
150
- <div class="method_details first">
151
- <h3 class="signature first" id="string_length-instance_method">
152
-
153
- #<strong>string_length</strong> &#x21d2; <tt><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></tt>
154
-
155
-
156
-
157
-
158
-
159
- </h3><div class="docstring">
160
- <div class="discussion">
161
-
162
- <p>Returns the length of the number&#39;s string representation.</p>
163
-
164
-
165
- </div>
166
- </div>
167
- <div class="tags">
168
-
169
- <div class="examples">
170
- <p class="tag_title">Examples:</p>
171
-
172
-
173
- <pre class="example code"><code><span class='int'>0</span><span class='period'>.</span><span class='id identifier rubyid_string_length'>string_length</span> <span class='comment'>#=&gt; 1
174
- </span><span class='int'>123</span><span class='period'>.</span><span class='id identifier rubyid_string_length'>string_length</span> <span class='comment'>#=&gt; 3
175
- </span><span class='op'>-</span><span class='int'>1</span><span class='period'>.</span><span class='id identifier rubyid_string_length'>string_length</span> <span class='comment'>#=&gt; 2</span></code></pre>
176
-
177
- </div>
178
-
179
-
180
- </div><table class="source_code">
181
- <tr>
182
- <td>
183
- <pre class="lines">
184
-
185
-
186
- 7
187
- 8
188
- 9
189
- 10
190
- 11
191
- 12</pre>
192
- </td>
193
- <td>
194
- <pre class="code"><span class="info file"># File 'lib/shenanigans/integer/string_length.rb', line 7</span>
195
-
196
- <span class='kw'>def</span> <span class='id identifier rubyid_string_length'>string_length</span>
197
- <span class='kw'>return</span> <span class='int'>1</span> <span class='kw'>if</span> <span class='id identifier rubyid_zero?'>zero?</span>
198
-
199
- <span class='id identifier rubyid_len'>len</span> <span class='op'>=</span> <span class='const'>Math</span><span class='period'>.</span><span class='id identifier rubyid_log10'>log10</span><span class='lparen'>(</span><span class='id identifier rubyid_abs'>abs</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_floor'>floor</span><span class='period'>.</span><span class='id identifier rubyid_next'>next</span>
200
- <span class='id identifier rubyid_positive?'>positive?</span> <span class='op'>?</span> <span class='id identifier rubyid_len'>len</span> <span class='op'>:</span> <span class='id identifier rubyid_len'>len</span><span class='period'>.</span><span class='id identifier rubyid_next'>next</span>
201
- <span class='kw'>end</span></pre>
202
- </td>
203
- </tr>
204
- </table>
205
- </div>
206
-
207
- </div>
208
-
209
- </div>
210
-
211
- <div id="footer">
212
- Generated on Tue May 5 19:54:28 2020 by
213
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
214
- 0.9.24 (ruby-2.7.1).
215
- </div>
216
-
217
- </div>
218
- </body>
219
- </html>