cowtech-extensions 2.1.3 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/.gitignore +1 -0
  2. data/.yardopts +1 -0
  3. data/README.md +10 -0
  4. data/Rakefile +6 -3
  5. data/cowtech-extensions.gemspec +9 -5
  6. data/doc/Cowtech.html +128 -0
  7. data/doc/Cowtech/Extensions.html +546 -0
  8. data/doc/Cowtech/Extensions/Boolean.html +297 -0
  9. data/doc/Cowtech/Extensions/DateTime.html +787 -0
  10. data/doc/Cowtech/Extensions/DateTime/ClassMethods.html +1592 -0
  11. data/doc/Cowtech/Extensions/Exceptions.html +125 -0
  12. data/doc/Cowtech/Extensions/Exceptions/Dump.html +133 -0
  13. data/doc/Cowtech/Extensions/Hash.html +393 -0
  14. data/doc/Cowtech/Extensions/Math.html +130 -0
  15. data/doc/Cowtech/Extensions/Math/ClassMethods.html +362 -0
  16. data/doc/Cowtech/Extensions/Object.html +1565 -0
  17. data/doc/Cowtech/Extensions/Pathname.html +225 -0
  18. data/doc/Cowtech/Extensions/Settings.html +1249 -0
  19. data/doc/Cowtech/Extensions/String.html +471 -0
  20. data/doc/Cowtech/Extensions/TimeZone.html +1210 -0
  21. data/doc/Cowtech/Extensions/TimeZone/ClassMethods.html +925 -0
  22. data/doc/Cowtech/Extensions/Version.html +189 -0
  23. data/doc/_index.html +305 -0
  24. data/doc/class_list.html +53 -0
  25. data/doc/css/common.css +1 -0
  26. data/doc/css/full_list.css +57 -0
  27. data/doc/css/style.css +328 -0
  28. data/doc/file.README.html +103 -0
  29. data/doc/file_list.html +55 -0
  30. data/doc/frames.html +28 -0
  31. data/doc/index.html +103 -0
  32. data/doc/js/app.js +214 -0
  33. data/doc/js/full_list.js +173 -0
  34. data/doc/js/jquery.js +4 -0
  35. data/doc/method_list.html +620 -0
  36. data/doc/top-level-namespace.html +112 -0
  37. data/lib/cowtech-extensions.rb +47 -16
  38. data/lib/cowtech-extensions/boolean.rb +8 -1
  39. data/lib/cowtech-extensions/datetime.rb +377 -71
  40. data/lib/cowtech-extensions/exceptions.rb +16 -0
  41. data/lib/cowtech-extensions/hash.rb +20 -9
  42. data/lib/cowtech-extensions/math.rb +15 -8
  43. data/lib/cowtech-extensions/object.rb +84 -27
  44. data/lib/cowtech-extensions/pathname.rb +10 -1
  45. data/lib/cowtech-extensions/settings.rb +120 -0
  46. data/lib/cowtech-extensions/string.rb +30 -3
  47. data/lib/cowtech-extensions/version.rb +11 -2
  48. data/spec/coverage_helper.rb +19 -0
  49. data/spec/cowtech-extensions/boolean_spec.rb +4 -0
  50. data/spec/cowtech-extensions/datetime_spec.rb +238 -79
  51. data/spec/cowtech-extensions/hash_spec.rb +5 -2
  52. data/spec/cowtech-extensions/math_spec.rb +14 -4
  53. data/spec/cowtech-extensions/object_spec.rb +19 -1
  54. data/spec/cowtech-extensions/pathname_spec.rb +5 -1
  55. data/spec/cowtech-extensions/settings_spec.rb +101 -0
  56. data/spec/cowtech-extensions/string_spec.rb +13 -0
  57. data/spec/cowtech-extensions_spec.rb +33 -13
  58. data/spec/spec_helper.rb +2 -5
  59. metadata +182 -97
  60. data/lib/cowtech-extensions/utils.rb +0 -74
@@ -0,0 +1,925 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: Cowtech::Extensions::TimeZone::ClassMethods
8
+
9
+ &mdash; Documentation by YARD 0.8.2.1
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../../../';
20
+ framesUrl = "../../../frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../../../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../../../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../../../_index.html">Index (C)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../../../Cowtech.html" title="Cowtech (module)">Cowtech</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../Extensions.html" title="Cowtech::Extensions (module)">Extensions</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../TimeZone.html" title="Cowtech::Extensions::TimeZone (module)">TimeZone</a></span></span>
36
+ &raquo;
37
+ <span class="title">ClassMethods</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../../../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../../../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../../../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Module: Cowtech::Extensions::TimeZone::ClassMethods
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ <dt class="r1 last">Defined in:</dt>
82
+ <dd class="r1 last">lib/cowtech-extensions/datetime.rb</dd>
83
+
84
+ </dl>
85
+ <div class="clear"></div>
86
+
87
+ <h2>Overview</h2><div class="docstring">
88
+ <div class="discussion">
89
+ <p>General methods.</p>
90
+
91
+
92
+ </div>
93
+ </div>
94
+ <div class="tags">
95
+
96
+
97
+ </div>
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+ <h2>
106
+ Instance Method Summary
107
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
108
+ </h2>
109
+
110
+ <ul class="summary">
111
+
112
+ <li class="public ">
113
+ <span class="summary_signature">
114
+
115
+ <a href="#find-instance_method" title="#find (instance method)">- (TimeZone) <strong>find</strong>(name, dst_label = nil) </a>
116
+
117
+
118
+
119
+ </span>
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+ <span class="summary_desc"><div class='inline'><p>Find a zone by its name.</p>
130
+ </div></span>
131
+
132
+ </li>
133
+
134
+
135
+ <li class="public ">
136
+ <span class="summary_signature">
137
+
138
+ <a href="#format_offset-instance_method" title="#format_offset (instance method)">- (String) <strong>format_offset</strong>(offset, colon = true) </a>
139
+
140
+
141
+
142
+ </span>
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+ <span class="summary_desc"><div class='inline'><p>Returns a +HH:MM formatted representation of the offset.</p>
153
+ </div></span>
154
+
155
+ </li>
156
+
157
+
158
+ <li class="public ">
159
+ <span class="summary_signature">
160
+
161
+ <a href="#list_all-instance_method" title="#list_all (instance method)">- (Array) <strong>list_all</strong>(with_dst = true, dst_label = nil) </a>
162
+
163
+
164
+
165
+ </span>
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+ <span class="summary_desc"><div class='inline'><p>Returns a list of names of all timezones.</p>
176
+ </div></span>
177
+
178
+ </li>
179
+
180
+
181
+ <li class="public ">
182
+ <span class="summary_signature">
183
+
184
+ <a href="#parameterize_zone-instance_method" title="#parameterize_zone (instance method)">- (String) <strong>parameterize_zone</strong>(tz, with_offset = true) </a>
185
+
186
+
187
+
188
+ </span>
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+ <span class="summary_desc"><div class='inline'><p>Returns a string representation of a timezone.</p>
199
+ </div></span>
200
+
201
+ </li>
202
+
203
+
204
+ <li class="public ">
205
+ <span class="summary_signature">
206
+
207
+ <a href="#rationalize_offset-instance_method" title="#rationalize_offset (instance method)">- (Rational) <strong>rationalize_offset</strong>(offset) </a>
208
+
209
+
210
+
211
+ </span>
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+ <span class="summary_desc"><div class='inline'><p>Returns an offset in rational value.</p>
222
+ </div></span>
223
+
224
+ </li>
225
+
226
+
227
+ <li class="public ">
228
+ <span class="summary_signature">
229
+
230
+ <a href="#unparameterize_zone-instance_method" title="#unparameterize_zone (instance method)">- (String|TimeZone) <strong>unparameterize_zone</strong>(tz, as_string = false, dst_label = nil) </a>
231
+
232
+
233
+
234
+ </span>
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+ <span class="summary_desc"><div class='inline'><p>Finds a parameterized timezone.</p>
245
+ </div></span>
246
+
247
+ </li>
248
+
249
+
250
+ </ul>
251
+
252
+
253
+
254
+
255
+ <div id="instance_method_details" class="method_details_list">
256
+ <h2>Instance Method Details</h2>
257
+
258
+
259
+ <div class="method_details first">
260
+ <h3 class="signature first" id="find-instance_method">
261
+
262
+ - (<tt><span class='object_link'><a href="../TimeZone.html" title="Cowtech::Extensions::TimeZone (module)">TimeZone</a></span></tt>) <strong>find</strong>(name, dst_label = nil)
263
+
264
+
265
+
266
+
267
+
268
+ </h3><div class="docstring">
269
+ <div class="discussion">
270
+ <p>Find a zone by its name.</p>
271
+
272
+
273
+ </div>
274
+ </div>
275
+ <div class="tags">
276
+ <p class="tag_title">Parameters:</p>
277
+ <ul class="param">
278
+
279
+ <li>
280
+
281
+ <span class='name'>name</span>
282
+
283
+
284
+ <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>)</span>
285
+
286
+
287
+
288
+ &mdash;
289
+ <div class='inline'><p>The zone name.</p>
290
+ </div>
291
+
292
+ </li>
293
+
294
+ <li>
295
+
296
+ <span class='name'>dst_label</span>
297
+
298
+
299
+ <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>)</span>
300
+
301
+
302
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
303
+
304
+
305
+ &mdash;
306
+ <div class='inline'><p>Label for the DST indication. Defaults to <code>(Daylight Saving Time)</code>.</p>
307
+ </div>
308
+
309
+ </li>
310
+
311
+ </ul>
312
+
313
+ <p class="tag_title">Returns:</p>
314
+ <ul class="return">
315
+
316
+ <li>
317
+
318
+
319
+ <span class='type'>(<tt><span class='object_link'><a href="../TimeZone.html" title="Cowtech::Extensions::TimeZone (module)">TimeZone</a></span></tt>)</span>
320
+
321
+
322
+
323
+ &mdash;
324
+ <div class='inline'><p>A timezone or <code>nil</code> if no zone was found.</p>
325
+ </div>
326
+
327
+ </li>
328
+
329
+ </ul>
330
+
331
+ </div><table class="source_code">
332
+ <tr>
333
+ <td>
334
+ <pre class="lines">
335
+
336
+
337
+ 290
338
+ 291
339
+ 292
340
+ 293
341
+ 294
342
+ 295
343
+ 296
344
+ 297
345
+ 298</pre>
346
+ </td>
347
+ <td>
348
+ <pre class="code"><span class="info file"># File 'lib/cowtech-extensions/datetime.rb', line 290</span>
349
+
350
+ <span class='kw'>def</span> <span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_dst_label'>dst_label</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
351
+ <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:zone</span><span class='rparen'>)</span> <span class='kw'>do</span>
352
+ <span class='op'>::</span><span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>TimeZone</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</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_zone'>zone</span><span class='op'>|</span>
353
+ <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:zone</span><span class='comma'>,</span> <span class='id identifier rubyid_zone'>zone</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='lbracket'>[</span><span class='id identifier rubyid_zone'>zone</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='comma'>,</span> <span class='id identifier rubyid_zone'>zone</span><span class='period'>.</span><span class='id identifier rubyid_to_s_with_dst'>to_s_with_dst</span><span class='lparen'>(</span><span class='id identifier rubyid_dst_label'>dst_label</span><span class='rparen'>)</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
354
+ <span class='kw'>end</span>
355
+
356
+ <span class='kw'>nil</span>
357
+ <span class='kw'>end</span>
358
+ <span class='kw'>end</span></pre>
359
+ </td>
360
+ </tr>
361
+ </table>
362
+ </div>
363
+
364
+ <div class="method_details ">
365
+ <h3 class="signature " id="format_offset-instance_method">
366
+
367
+ - (<tt><span class='object_link'><a href="../String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>) <strong>format_offset</strong>(offset, colon = true)
368
+
369
+
370
+
371
+
372
+
373
+ </h3><div class="docstring">
374
+ <div class="discussion">
375
+ <p>Returns a +HH:MM formatted representation of the offset.</p>
376
+
377
+
378
+ </div>
379
+ </div>
380
+ <div class="tags">
381
+ <p class="tag_title">Parameters:</p>
382
+ <ul class="param">
383
+
384
+ <li>
385
+
386
+ <span class='name'>offset</span>
387
+
388
+
389
+ <span class='type'>(<tt>Rational|Fixnum</tt>)</span>
390
+
391
+
392
+
393
+ &mdash;
394
+ <div class='inline'><p>The offset to represent, in seconds or as a rational.</p>
395
+ </div>
396
+
397
+ </li>
398
+
399
+ <li>
400
+
401
+ <span class='name'>colon</span>
402
+
403
+
404
+ <span class='type'>(<tt><span class='object_link'><a href="../Boolean.html" title="Cowtech::Extensions::Boolean (module)">Boolean</a></span></tt>)</span>
405
+
406
+
407
+ <em class="default">(defaults to: <tt>true</tt>)</em>
408
+
409
+
410
+ &mdash;
411
+ <div class='inline'><p>If to put the colon in the output string.</p>
412
+ </div>
413
+
414
+ </li>
415
+
416
+ </ul>
417
+
418
+ <p class="tag_title">Returns:</p>
419
+ <ul class="return">
420
+
421
+ <li>
422
+
423
+
424
+ <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>)</span>
425
+
426
+
427
+
428
+ &mdash;
429
+ <div class='inline'><p>The formatted offset.</p>
430
+ </div>
431
+
432
+ </li>
433
+
434
+ </ul>
435
+
436
+ </div><table class="source_code">
437
+ <tr>
438
+ <td>
439
+ <pre class="lines">
440
+
441
+
442
+ 280
443
+ 281
444
+ 282
445
+ 283</pre>
446
+ </td>
447
+ <td>
448
+ <pre class="code"><span class="info file"># File 'lib/cowtech-extensions/datetime.rb', line 280</span>
449
+
450
+ <span class='kw'>def</span> <span class='id identifier rubyid_format_offset'>format_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_offset'>offset</span><span class='comma'>,</span> <span class='id identifier rubyid_colon'>colon</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
451
+ <span class='id identifier rubyid_offset'>offset</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_offset'>offset</span> <span class='op'>*</span> <span class='int'>86400</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='kw'>if</span> <span class='id identifier rubyid_offset'>offset</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'>Rational</span><span class='rparen'>)</span>
452
+ <span class='id identifier rubyid_offset'>offset</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'>Fixnum</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_seconds_to_utc_offset'>seconds_to_utc_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_offset'>offset</span><span class='comma'>,</span> <span class='id identifier rubyid_colon'>colon</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
453
+ <span class='kw'>end</span></pre>
454
+ </td>
455
+ </tr>
456
+ </table>
457
+ </div>
458
+
459
+ <div class="method_details ">
460
+ <h3 class="signature " id="list_all-instance_method">
461
+
462
+ - (<tt>Array</tt>) <strong>list_all</strong>(with_dst = true, dst_label = nil)
463
+
464
+
465
+
466
+
467
+
468
+ </h3><div class="docstring">
469
+ <div class="discussion">
470
+ <p>Returns a list of names of all timezones.</p>
471
+
472
+
473
+ </div>
474
+ </div>
475
+ <div class="tags">
476
+ <p class="tag_title">Parameters:</p>
477
+ <ul class="param">
478
+
479
+ <li>
480
+
481
+ <span class='name'>with_dst</span>
482
+
483
+
484
+ <span class='type'>(<tt><span class='object_link'><a href="../Boolean.html" title="Cowtech::Extensions::Boolean (module)">Boolean</a></span></tt>)</span>
485
+
486
+
487
+ <em class="default">(defaults to: <tt>true</tt>)</em>
488
+
489
+
490
+ &mdash;
491
+ <div class='inline'><p>If include DST version of the zones.</p>
492
+ </div>
493
+
494
+ </li>
495
+
496
+ <li>
497
+
498
+ <span class='name'>dst_label</span>
499
+
500
+
501
+ <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>)</span>
502
+
503
+
504
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
505
+
506
+
507
+ &mdash;
508
+ <div class='inline'><p>Label for the DST indication. Defaults to <code>(Daylight Saving Time)</code>.</p>
509
+ </div>
510
+
511
+ </li>
512
+
513
+ </ul>
514
+
515
+ <p class="tag_title">Returns:</p>
516
+ <ul class="return">
517
+
518
+ <li>
519
+
520
+
521
+ <span class='type'>(<tt>Array</tt>)</span>
522
+
523
+
524
+
525
+ &mdash;
526
+ <div class='inline'><p>A list of names of timezones.</p>
527
+ </div>
528
+
529
+ </li>
530
+
531
+ </ul>
532
+
533
+ </div><table class="source_code">
534
+ <tr>
535
+ <td>
536
+ <pre class="lines">
537
+
538
+
539
+ 305
540
+ 306
541
+ 307
542
+ 308
543
+ 309
544
+ 310
545
+ 311
546
+ 312
547
+ 313
548
+ 314
549
+ 315
550
+ 316
551
+ 317
552
+ 318
553
+ 319</pre>
554
+ </td>
555
+ <td>
556
+ <pre class="code"><span class="info file"># File 'lib/cowtech-extensions/datetime.rb', line 305</span>
557
+
558
+ <span class='kw'>def</span> <span class='id identifier rubyid_list_all'>list_all</span><span class='lparen'>(</span><span class='id identifier rubyid_with_dst'>with_dst</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_dst_label'>dst_label</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
559
+ <span class='id identifier rubyid_dst_key'>dst_key</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DST-</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_dst_label'>dst_label</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span>
560
+ <span class='ivar'>@zones_names</span> <span class='op'>||=</span> <span class='lbrace'>{</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>STANDARD</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>TimeZone</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:to_s</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
561
+
562
+ <span class='kw'>if</span> <span class='id identifier rubyid_with_dst'>with_dst</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@zones_names</span><span class='lbracket'>[</span><span class='id identifier rubyid_dst_key'>dst_key</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='kw'>then</span>
563
+ <span class='ivar'>@zones_names</span><span class='lbracket'>[</span><span class='id identifier rubyid_dst_key'>dst_key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
564
+
565
+ <span class='op'>::</span><span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>TimeZone</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</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_zone'>zone</span><span class='op'>|</span>
566
+ <span class='ivar'>@zones_names</span><span class='lbracket'>[</span><span class='id identifier rubyid_dst_key'>dst_key</span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_zone'>zone</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
567
+ <span class='ivar'>@zones_names</span><span class='lbracket'>[</span><span class='id identifier rubyid_dst_key'>dst_key</span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_zone'>zone</span><span class='period'>.</span><span class='id identifier rubyid_to_s_with_dst'>to_s_with_dst</span><span class='lparen'>(</span><span class='id identifier rubyid_dst_label'>dst_label</span><span class='rparen'>)</span>
568
+ <span class='kw'>end</span>
569
+ <span class='kw'>end</span>
570
+
571
+ <span class='ivar'>@zones_names</span><span class='lbracket'>[</span><span class='id identifier rubyid_with_dst'>with_dst</span> <span class='op'>?</span> <span class='id identifier rubyid_dst_key'>dst_key</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>STANDARD</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span>
572
+ <span class='kw'>end</span></pre>
573
+ </td>
574
+ </tr>
575
+ </table>
576
+ </div>
577
+
578
+ <div class="method_details ">
579
+ <h3 class="signature " id="parameterize_zone-instance_method">
580
+
581
+ - (<tt><span class='object_link'><a href="../String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>) <strong>parameterize_zone</strong>(tz, with_offset = true)
582
+
583
+
584
+
585
+
586
+
587
+ </h3><div class="docstring">
588
+ <div class="discussion">
589
+ <p>Returns a string representation of a timezone.</p>
590
+
591
+ <pre class="code ruby"><code><span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_parameterize_zone'>parameterize_zone</span><span class='lparen'>(</span><span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>TimeZone</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Pacific Time (US &amp; Canada)</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
592
+ <span class='comment'># =&gt; &quot;-0800@pacific-time-us-canada&quot;
593
+ </span></code></pre>
594
+
595
+
596
+ </div>
597
+ </div>
598
+ <div class="tags">
599
+ <p class="tag_title">Parameters:</p>
600
+ <ul class="param">
601
+
602
+ <li>
603
+
604
+ <span class='name'>tz</span>
605
+
606
+
607
+ <span class='type'>(<tt><span class='object_link'><a href="../TimeZone.html" title="Cowtech::Extensions::TimeZone (module)">TimeZone</a></span></tt>)</span>
608
+
609
+
610
+
611
+ &mdash;
612
+ <div class='inline'><p>The zone to represent.</p>
613
+ </div>
614
+
615
+ </li>
616
+
617
+ <li>
618
+
619
+ <span class='name'>with_offset</span>
620
+
621
+
622
+ <span class='type'>(<tt><span class='object_link'><a href="../Boolean.html" title="Cowtech::Extensions::Boolean (module)">Boolean</a></span></tt>)</span>
623
+
624
+
625
+ <em class="default">(defaults to: <tt>true</tt>)</em>
626
+
627
+
628
+ &mdash;
629
+ <div class='inline'><p>If to include offset into the representation.</p>
630
+ </div>
631
+
632
+ </li>
633
+
634
+ </ul>
635
+
636
+ <p class="tag_title">Returns:</p>
637
+ <ul class="return">
638
+
639
+ <li>
640
+
641
+
642
+ <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>)</span>
643
+
644
+
645
+
646
+ &mdash;
647
+ <div class='inline'><p>A string representation which can be used for searches.</p>
648
+ </div>
649
+
650
+ </li>
651
+
652
+ </ul>
653
+
654
+ </div><table class="source_code">
655
+ <tr>
656
+ <td>
657
+ <pre class="lines">
658
+
659
+
660
+ 330
661
+ 331
662
+ 332
663
+ 333
664
+ 334
665
+ 335
666
+ 336
667
+ 337
668
+ 338
669
+ 339
670
+ 340</pre>
671
+ </td>
672
+ <td>
673
+ <pre class="code"><span class="info file"># File 'lib/cowtech-extensions/datetime.rb', line 330</span>
674
+
675
+ <span class='kw'>def</span> <span class='id identifier rubyid_parameterize_zone'>parameterize_zone</span><span class='lparen'>(</span><span class='id identifier rubyid_tz'>tz</span><span class='comma'>,</span> <span class='id identifier rubyid_with_offset'>with_offset</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
676
+ <span class='id identifier rubyid_tz'>tz</span> <span class='op'>=</span> <span class='id identifier rubyid_tz'>tz</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_tz'>tz</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'>String</span><span class='rparen'>)</span>
677
+
678
+ <span class='kw'>if</span> <span class='id identifier rubyid_tz'>tz</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^(\([a-z]+([+-])(\d{2})(:?)(\d{2})\)\s(.+))$</span><span class='regexp_end'>/i</span></span> <span class='kw'>then</span>
679
+ <span class='id identifier rubyid_with_offset'>with_offset</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='backref'>$2</span><span class='rbrace'>}</span><span class='embexpr_beg'>#{</span><span class='backref'>$3</span><span class='rbrace'>}</span><span class='embexpr_beg'>#{</span><span class='backref'>$5</span><span class='rbrace'>}</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='backref'>$6</span><span class='period'>.</span><span class='id identifier rubyid_parameterize'>parameterize</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span> <span class='op'>:</span> <span class='backref'>$6</span><span class='period'>.</span><span class='id identifier rubyid_parameterize'>parameterize</span>
680
+ <span class='kw'>elsif</span> <span class='op'>!</span><span class='id identifier rubyid_with_offset'>with_offset</span> <span class='kw'>then</span>
681
+ <span class='id identifier rubyid_tz'>tz</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^([+-]?(\d{2})(:?)(\d{2})@)</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
682
+ <span class='kw'>else</span>
683
+ <span class='id identifier rubyid_tz'>tz</span><span class='period'>.</span><span class='id identifier rubyid_parameterize'>parameterize</span>
684
+ <span class='kw'>end</span>
685
+ <span class='kw'>end</span></pre>
686
+ </td>
687
+ </tr>
688
+ </table>
689
+ </div>
690
+
691
+ <div class="method_details ">
692
+ <h3 class="signature " id="rationalize_offset-instance_method">
693
+
694
+ - (<tt>Rational</tt>) <strong>rationalize_offset</strong>(offset)
695
+
696
+
697
+
698
+
699
+
700
+ </h3><div class="docstring">
701
+ <div class="discussion">
702
+ <p>Returns an offset in rational value.</p>
703
+
704
+
705
+ </div>
706
+ </div>
707
+ <div class="tags">
708
+ <p class="tag_title">Parameters:</p>
709
+ <ul class="param">
710
+
711
+ <li>
712
+
713
+ <span class='name'>offset</span>
714
+
715
+
716
+ <span class='type'>(<tt>Fixnum</tt>)</span>
717
+
718
+
719
+
720
+ &mdash;
721
+ <div class='inline'><p>The offset to convert.</p>
722
+ </div>
723
+
724
+ </li>
725
+
726
+ </ul>
727
+
728
+ <p class="tag_title">Returns:</p>
729
+ <ul class="return">
730
+
731
+ <li>
732
+
733
+
734
+ <span class='type'>(<tt>Rational</tt>)</span>
735
+
736
+
737
+
738
+ &mdash;
739
+ <div class='inline'><p>The converted offset.</p>
740
+ </div>
741
+
742
+ </li>
743
+
744
+ </ul>
745
+
746
+ </div><table class="source_code">
747
+ <tr>
748
+ <td>
749
+ <pre class="lines">
750
+
751
+
752
+ 270
753
+ 271
754
+ 272
755
+ 273</pre>
756
+ </td>
757
+ <td>
758
+ <pre class="code"><span class="info file"># File 'lib/cowtech-extensions/datetime.rb', line 270</span>
759
+
760
+ <span class='kw'>def</span> <span class='id identifier rubyid_rationalize_offset'>rationalize_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_offset'>offset</span><span class='rparen'>)</span>
761
+ <span class='id identifier rubyid_offset'>offset</span> <span class='op'>=</span> <span class='id identifier rubyid_offset'>offset</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:offset</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_offset'>offset</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'>Fixnum</span><span class='rparen'>)</span>
762
+ <span class='op'>::</span><span class='const'>TZInfo</span><span class='op'>::</span><span class='const'>OffsetRationals</span><span class='period'>.</span><span class='id identifier rubyid_rational_for_offset'>rational_for_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_offset'>offset</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span><span class='rparen'>)</span>
763
+ <span class='kw'>end</span></pre>
764
+ </td>
765
+ </tr>
766
+ </table>
767
+ </div>
768
+
769
+ <div class="method_details ">
770
+ <h3 class="signature " id="unparameterize_zone-instance_method">
771
+
772
+ - (<tt><span class='object_link'><a href="../String.html" title="Cowtech::Extensions::String (module)">String</a></span>|<span class='object_link'><a href="../TimeZone.html" title="Cowtech::Extensions::TimeZone (module)">TimeZone</a></span></tt>) <strong>unparameterize_zone</strong>(tz, as_string = false, dst_label = nil)
773
+
774
+
775
+
776
+
777
+
778
+ </h3><div class="docstring">
779
+ <div class="discussion">
780
+ <p>Finds a parameterized timezone.</p>
781
+
782
+
783
+ </div>
784
+ </div>
785
+ <div class="tags">
786
+ <p class="tag_title">Parameters:</p>
787
+ <ul class="param">
788
+
789
+ <li>
790
+
791
+ <span class='name'>tz</span>
792
+
793
+
794
+ <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>)</span>
795
+
796
+
797
+
798
+ &mdash;
799
+ <div class='inline'><p>The zone to unparameterize.</p>
800
+ </div>
801
+
802
+ </li>
803
+
804
+ <li>
805
+
806
+ <span class='name'>as_string</span>
807
+
808
+
809
+ <span class='type'>(<tt><span class='object_link'><a href="../Boolean.html" title="Cowtech::Extensions::Boolean (module)">Boolean</a></span></tt>)</span>
810
+
811
+
812
+ <em class="default">(defaults to: <tt>false</tt>)</em>
813
+
814
+
815
+ &mdash;
816
+ <div class='inline'><p>If return just the zone name.</p>
817
+ </div>
818
+
819
+ </li>
820
+
821
+ <li>
822
+
823
+ <span class='name'>dst_label</span>
824
+
825
+
826
+ <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>)</span>
827
+
828
+
829
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
830
+
831
+
832
+ &mdash;
833
+ <div class='inline'><p>Label for the DST indication. Defaults to <code>(Daylight Saving Time)</code>.</p>
834
+ </div>
835
+
836
+ </li>
837
+
838
+ </ul>
839
+
840
+ <p class="tag_title">Returns:</p>
841
+ <ul class="return">
842
+
843
+ <li>
844
+
845
+
846
+ <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Cowtech::Extensions::String (module)">String</a></span>|<span class='object_link'><a href="../TimeZone.html" title="Cowtech::Extensions::TimeZone (module)">TimeZone</a></span></tt>)</span>
847
+
848
+
849
+
850
+ &mdash;
851
+ <div class='inline'><p>The found timezone or <code>nil</code> if the zone is not valid.</p>
852
+ </div>
853
+
854
+ </li>
855
+
856
+ </ul>
857
+
858
+ <p class="tag_title">See Also:</p>
859
+ <ul class="see">
860
+
861
+ <li>DateTime#parameterize_zone</li>
862
+
863
+ </ul>
864
+
865
+ </div><table class="source_code">
866
+ <tr>
867
+ <td>
868
+ <pre class="lines">
869
+
870
+
871
+ 349
872
+ 350
873
+ 351
874
+ 352
875
+ 353
876
+ 354
877
+ 355
878
+ 356
879
+ 357
880
+ 358
881
+ 359
882
+ 360
883
+ 361
884
+ 362
885
+ 363
886
+ 364
887
+ 365</pre>
888
+ </td>
889
+ <td>
890
+ <pre class="code"><span class="info file"># File 'lib/cowtech-extensions/datetime.rb', line 349</span>
891
+
892
+ <span class='kw'>def</span> <span class='id identifier rubyid_unparameterize_zone'>unparameterize_zone</span><span class='lparen'>(</span><span class='id identifier rubyid_tz'>tz</span><span class='comma'>,</span> <span class='id identifier rubyid_as_string'>as_string</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_dst_label'>dst_label</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
893
+ <span class='id identifier rubyid_tz'>tz</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parameterize_zone'>parameterize_zone</span><span class='lparen'>(</span><span class='id identifier rubyid_tz'>tz</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span>
894
+
895
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:zone</span><span class='rparen'>)</span> <span class='kw'>do</span>
896
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_list_all'>list_all</span><span class='lparen'>(</span><span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_dst_label'>dst_label</span><span class='rparen'>)</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_zone'>zone</span><span class='op'>|</span>
897
+ <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:zone</span><span class='comma'>,</span> <span class='id identifier rubyid_zone'>zone</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parameterize_zone'>parameterize_zone</span><span class='lparen'>(</span><span class='id identifier rubyid_zone'>zone</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='id identifier rubyid_tz'>tz</span>
898
+ <span class='kw'>end</span>
899
+
900
+ <span class='kw'>nil</span>
901
+ <span class='kw'>end</span>
902
+
903
+ <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span> <span class='kw'>then</span>
904
+ <span class='lparen'>(</span><span class='id identifier rubyid_as_string'>as_string</span> <span class='op'>?</span> <span class='id identifier rubyid_rv'>rv</span> <span class='op'>:</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_dst_label'>dst_label</span><span class='rparen'>)</span><span class='rparen'>)</span>
905
+ <span class='kw'>else</span>
906
+ <span class='kw'>nil</span>
907
+ <span class='kw'>end</span>
908
+ <span class='kw'>end</span></pre>
909
+ </td>
910
+ </tr>
911
+ </table>
912
+ </div>
913
+
914
+ </div>
915
+
916
+ </div>
917
+
918
+ <div id="footer">
919
+ Generated on Thu Jul 19 17:17:51 2012 by
920
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
921
+ 0.8.2.1 (ruby-1.9.2).
922
+ </div>
923
+
924
+ </body>
925
+ </html>