cowtech-extensions 2.1.3 → 2.5.0

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 (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,297 @@
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::Boolean
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 (B)</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>
36
+ &raquo;
37
+ <span class="title">Boolean</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::Boolean
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+ <dt class="r1">Extended by:</dt>
77
+ <dd class="r1">ActiveSupport::Concern</dd>
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+ <dt class="r2 last">Defined in:</dt>
86
+ <dd class="r2 last">lib/cowtech-extensions/boolean.rb</dd>
87
+
88
+ </dl>
89
+ <div class="clear"></div>
90
+
91
+ <h2>Overview</h2><div class="docstring">
92
+ <div class="discussion">
93
+ <p>Extension for the boolean values.</p>
94
+
95
+
96
+ </div>
97
+ </div>
98
+ <div class="tags">
99
+
100
+
101
+ </div>
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ <h2>
110
+ Instance Method Summary
111
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
112
+ </h2>
113
+
114
+ <ul class="summary">
115
+
116
+ <li class="public ">
117
+ <span class="summary_signature">
118
+
119
+ <a href="#to_i-instance_method" title="#to_i (instance method)">- (Fixnum) <strong>to_i</strong> </a>
120
+
121
+
122
+
123
+ </span>
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+ <span class="summary_desc"><div class='inline'><p>Converts the boolean to an integer.</p>
134
+ </div></span>
135
+
136
+ </li>
137
+
138
+
139
+ <li class="public ">
140
+ <span class="summary_signature">
141
+
142
+ <a href="#value-instance_method" title="#value (instance method)">- (Boolean) <strong>value</strong> </a>
143
+
144
+
145
+
146
+ </span>
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+ <span class="summary_desc"><div class='inline'><p>Returns the boolean itself for use in form helpers.</p>
157
+ </div></span>
158
+
159
+ </li>
160
+
161
+
162
+ </ul>
163
+
164
+
165
+
166
+
167
+
168
+ <div id="instance_method_details" class="method_details_list">
169
+ <h2>Instance Method Details</h2>
170
+
171
+
172
+ <div class="method_details first">
173
+ <h3 class="signature first" id="to_i-instance_method">
174
+
175
+ - (<tt>Fixnum</tt>) <strong>to_i</strong>
176
+
177
+
178
+
179
+
180
+
181
+ </h3><div class="docstring">
182
+ <div class="discussion">
183
+ <p>Converts the boolean to an integer.</p>
184
+
185
+
186
+ </div>
187
+ </div>
188
+ <div class="tags">
189
+
190
+ <p class="tag_title">Returns:</p>
191
+ <ul class="return">
192
+
193
+ <li>
194
+
195
+
196
+ <span class='type'>(<tt>Fixnum</tt>)</span>
197
+
198
+
199
+
200
+ &mdash;
201
+ <div class='inline'><p><code>1</code> for <code>true</code>, <code>0</code> for <code>false</code>.</p>
202
+ </div>
203
+
204
+ </li>
205
+
206
+ </ul>
207
+
208
+ </div><table class="source_code">
209
+ <tr>
210
+ <td>
211
+ <pre class="lines">
212
+
213
+
214
+ 16
215
+ 17
216
+ 18</pre>
217
+ </td>
218
+ <td>
219
+ <pre class="code"><span class="info file"># File 'lib/cowtech-extensions/boolean.rb', line 16</span>
220
+
221
+ <span class='kw'>def</span> <span class='id identifier rubyid_to_i'>to_i</span>
222
+ <span class='lparen'>(</span><span class='kw'>self</span> <span class='op'>==</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='int'>1</span> <span class='op'>:</span> <span class='int'>0</span>
223
+ <span class='kw'>end</span></pre>
224
+ </td>
225
+ </tr>
226
+ </table>
227
+ </div>
228
+
229
+ <div class="method_details ">
230
+ <h3 class="signature " id="value-instance_method">
231
+
232
+ - (<tt><span class='object_link'><a href="" title="Cowtech::Extensions::Boolean (module)">Boolean</a></span></tt>) <strong>value</strong>
233
+
234
+
235
+
236
+
237
+
238
+ </h3><div class="docstring">
239
+ <div class="discussion">
240
+ <p>Returns the boolean itself for use in form helpers.</p>
241
+
242
+
243
+ </div>
244
+ </div>
245
+ <div class="tags">
246
+
247
+ <p class="tag_title">Returns:</p>
248
+ <ul class="return">
249
+
250
+ <li>
251
+
252
+
253
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Cowtech::Extensions::Boolean (module)">Boolean</a></span></tt>)</span>
254
+
255
+
256
+
257
+ &mdash;
258
+ <div class='inline'><p>The boolean value.</p>
259
+ </div>
260
+
261
+ </li>
262
+
263
+ </ul>
264
+
265
+ </div><table class="source_code">
266
+ <tr>
267
+ <td>
268
+ <pre class="lines">
269
+
270
+
271
+ 23
272
+ 24
273
+ 25</pre>
274
+ </td>
275
+ <td>
276
+ <pre class="code"><span class="info file"># File 'lib/cowtech-extensions/boolean.rb', line 23</span>
277
+
278
+ <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span>
279
+ <span class='kw'>self</span>
280
+ <span class='kw'>end</span></pre>
281
+ </td>
282
+ </tr>
283
+ </table>
284
+ </div>
285
+
286
+ </div>
287
+
288
+ </div>
289
+
290
+ <div id="footer">
291
+ Generated on Thu Jul 19 17:17:50 2012 by
292
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
293
+ 0.8.2.1 (ruby-1.9.2).
294
+ </div>
295
+
296
+ </body>
297
+ </html>
@@ -0,0 +1,787 @@
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::DateTime
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 (D)</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>
36
+ &raquo;
37
+ <span class="title">DateTime</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::DateTime
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+ <dt class="r1">Extended by:</dt>
77
+ <dd class="r1">ActiveSupport::Concern</dd>
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+ <dt class="r2 last">Defined in:</dt>
86
+ <dd class="r2 last">lib/cowtech-extensions/datetime.rb</dd>
87
+
88
+ </dl>
89
+ <div class="clear"></div>
90
+
91
+ <h2>Overview</h2><div class="docstring">
92
+ <div class="discussion">
93
+ <p>Extensions for date and time objects.</p>
94
+
95
+
96
+ </div>
97
+ </div>
98
+ <div class="tags">
99
+
100
+
101
+ </div><h2>Defined Under Namespace</h2>
102
+ <p class="children">
103
+
104
+
105
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="DateTime/ClassMethods.html" title="Cowtech::Extensions::DateTime::ClassMethods (module)">ClassMethods</a></span>
106
+
107
+
108
+
109
+
110
+ </p>
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+ <h2>
120
+ Instance Method Summary
121
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
122
+ </h2>
123
+
124
+ <ul class="summary">
125
+
126
+ <li class="public ">
127
+ <span class="summary_signature">
128
+
129
+ <a href="#in_months-instance_method" title="#in_months (instance method)">- (Fixnum) <strong>in_months</strong>(base = nil) </a>
130
+
131
+
132
+
133
+ </span>
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+ <span class="summary_desc"><div class='inline'><p>Returns the number of months passed between the beginning of the base year and the current date.</p>
144
+ </div></span>
145
+
146
+ </li>
147
+
148
+
149
+ <li class="public ">
150
+ <span class="summary_signature">
151
+
152
+ <a href="#local_lstrftime-instance_method" title="#local_lstrftime (instance method)">- (String) <strong>local_lstrftime</strong>(format = nil) </a>
153
+
154
+
155
+
156
+ </span>
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+ <span class="summary_desc"><div class='inline'><p>Formats a datetime in the current timezone, looking up also custom formats.</p>
167
+ </div></span>
168
+
169
+ </li>
170
+
171
+
172
+ <li class="public ">
173
+ <span class="summary_signature">
174
+
175
+ <a href="#local_strftime-instance_method" title="#local_strftime (instance method)">- (String) <strong>local_strftime</strong>(format = nil) </a>
176
+
177
+
178
+
179
+ </span>
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+ <span class="summary_desc"><div class='inline'><p>Formats a datetime in the current timezone.</p>
190
+ </div></span>
191
+
192
+ </li>
193
+
194
+
195
+ <li class="public ">
196
+ <span class="summary_signature">
197
+
198
+ <a href="#lstrftime-instance_method" title="#lstrftime (instance method)">- (String) <strong>lstrftime</strong>(format = nil) </a>
199
+
200
+
201
+
202
+ </span>
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+ <span class="summary_desc"><div class='inline'><p>Formats a datetime, looking up also custom formats.</p>
213
+ </div></span>
214
+
215
+ </li>
216
+
217
+
218
+ <li class="public ">
219
+ <span class="summary_signature">
220
+
221
+ <a href="#padded_month-instance_method" title="#padded_month (instance method)">- (String) <strong>padded_month</strong> </a>
222
+
223
+
224
+
225
+ </span>
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+ <span class="summary_desc"><div class='inline'><p>Returns the current month number with leading 0.</p>
236
+ </div></span>
237
+
238
+ </li>
239
+
240
+
241
+ <li class="public ">
242
+ <span class="summary_signature">
243
+
244
+ <a href="#utc_time-instance_method" title="#utc_time (instance method)">- (UTC::Time) <strong>utc_time</strong> </a>
245
+
246
+
247
+
248
+ </span>
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+ <span class="summary_desc"><div class='inline'><p>Returns the UTC::Time representation of the current datetime.</p>
259
+ </div></span>
260
+
261
+ </li>
262
+
263
+
264
+ </ul>
265
+
266
+
267
+
268
+
269
+
270
+ <div id="instance_method_details" class="method_details_list">
271
+ <h2>Instance Method Details</h2>
272
+
273
+
274
+ <div class="method_details first">
275
+ <h3 class="signature first" id="in_months-instance_method">
276
+
277
+ - (<tt>Fixnum</tt>) <strong>in_months</strong>(base = nil)
278
+
279
+
280
+
281
+
282
+
283
+ </h3><div class="docstring">
284
+ <div class="discussion">
285
+ <p>Returns the number of months passed between the beginning of the base year and the current date.</p>
286
+
287
+ <pre class="code ruby"><code><span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_civil'>civil</span><span class='lparen'>(</span><span class='int'>2012</span><span class='comma'>,</span> <span class='int'>6</span><span class='comma'>,</span> <span class='int'>1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_in_months'>in_months</span><span class='lparen'>(</span><span class='int'>2011</span><span class='rparen'>)</span>
288
+ <span class='comment'># =&gt; 18
289
+ </span></code></pre>
290
+
291
+
292
+ </div>
293
+ </div>
294
+ <div class="tags">
295
+ <p class="tag_title">Parameters:</p>
296
+ <ul class="param">
297
+
298
+ <li>
299
+
300
+ <span class='name'>base</span>
301
+
302
+
303
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Cowtech::Extensions::DateTime (module)">DateTime</a></span></tt>)</span>
304
+
305
+
306
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
307
+
308
+
309
+ &mdash;
310
+ <div class='inline'><p>The base year to start computation from. Default to current year.</p>
311
+ </div>
312
+
313
+ </li>
314
+
315
+ </ul>
316
+
317
+ <p class="tag_title">Returns:</p>
318
+ <ul class="return">
319
+
320
+ <li>
321
+
322
+
323
+ <span class='type'>(<tt>Fixnum</tt>)</span>
324
+
325
+
326
+
327
+ &mdash;
328
+ <div class='inline'><p>Returns the number of months passed between the beginning of the base year and the current date.</p>
329
+ </div>
330
+
331
+ </li>
332
+
333
+ </ul>
334
+
335
+ </div><table class="source_code">
336
+ <tr>
337
+ <td>
338
+ <pre class="lines">
339
+
340
+
341
+ 194
342
+ 195
343
+ 196
344
+ 197</pre>
345
+ </td>
346
+ <td>
347
+ <pre class="code"><span class="info file"># File 'lib/cowtech-extensions/datetime.rb', line 194</span>
348
+
349
+ <span class='kw'>def</span> <span class='id identifier rubyid_in_months'>in_months</span><span class='lparen'>(</span><span class='id identifier rubyid_base'>base</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
350
+ <span class='id identifier rubyid_base'>base</span> <span class='op'>||=</span> <span class='op'>::</span><span class='const'>Date</span><span class='period'>.</span><span class='id identifier rubyid_today'>today</span><span class='period'>.</span><span class='id identifier rubyid_year'>year</span>
351
+ <span class='lparen'>(</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_year'>year</span><span class='rparen'>)</span> <span class='op'>-</span> <span class='id identifier rubyid_base'>base</span><span class='rparen'>)</span> <span class='op'>*</span> <span class='int'>12</span> <span class='op'>+</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_month'>month</span>
352
+ <span class='kw'>end</span></pre>
353
+ </td>
354
+ </tr>
355
+ </table>
356
+ </div>
357
+
358
+ <div class="method_details ">
359
+ <h3 class="signature " id="local_lstrftime-instance_method">
360
+
361
+ - (<tt><span class='object_link'><a href="String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>) <strong>local_lstrftime</strong>(format = nil)
362
+
363
+
364
+
365
+
366
+
367
+ </h3><div class="docstring">
368
+ <div class="discussion">
369
+ <p>Formats a datetime in the current timezone, looking up also custom formats.</p>
370
+
371
+
372
+ </div>
373
+ </div>
374
+ <div class="tags">
375
+ <p class="tag_title">Parameters:</p>
376
+ <ul class="param">
377
+
378
+ <li>
379
+
380
+ <span class='name'>format</span>
381
+
382
+
383
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>)</span>
384
+
385
+
386
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
387
+
388
+
389
+ &mdash;
390
+ <div class='inline'><p>A format or a custom format name.</p>
391
+ </div>
392
+
393
+ </li>
394
+
395
+ </ul>
396
+
397
+ <p class="tag_title">Returns:</p>
398
+ <ul class="return">
399
+
400
+ <li>
401
+
402
+
403
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>)</span>
404
+
405
+
406
+
407
+ &mdash;
408
+ <div class='inline'><p>The formatted date.</p>
409
+ </div>
410
+
411
+ </li>
412
+
413
+ </ul>
414
+
415
+ <p class="tag_title">See Also:</p>
416
+ <ul class="see">
417
+
418
+ <li><span class='object_link'><a href="Settings.html#setup_date_formats-instance_method" title="Cowtech::Extensions::Settings#setup_date_formats (method)">Settings#setup_date_formats</a></span></li>
419
+
420
+ </ul>
421
+
422
+ </div><table class="source_code">
423
+ <tr>
424
+ <td>
425
+ <pre class="lines">
426
+
427
+
428
+ 255
429
+ 256
430
+ 257</pre>
431
+ </td>
432
+ <td>
433
+ <pre class="code"><span class="info file"># File 'lib/cowtech-extensions/datetime.rb', line 255</span>
434
+
435
+ <span class='kw'>def</span> <span class='id identifier rubyid_local_lstrftime'>local_lstrftime</span><span class='lparen'>(</span><span class='id identifier rubyid_format'>format</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
436
+ <span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:in_time_zone</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_in_time_zone'>in_time_zone</span> <span class='op'>:</span> <span class='kw'>self</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_lstrftime'>lstrftime</span><span class='lparen'>(</span><span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span>
437
+ <span class='kw'>end</span></pre>
438
+ </td>
439
+ </tr>
440
+ </table>
441
+ </div>
442
+
443
+ <div class="method_details ">
444
+ <h3 class="signature " id="local_strftime-instance_method">
445
+
446
+ - (<tt><span class='object_link'><a href="String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>) <strong>local_strftime</strong>(format = nil)
447
+
448
+
449
+
450
+
451
+
452
+ </h3><div class="docstring">
453
+ <div class="discussion">
454
+ <p>Formats a datetime in the current timezone.</p>
455
+
456
+
457
+ </div>
458
+ </div>
459
+ <div class="tags">
460
+ <p class="tag_title">Parameters:</p>
461
+ <ul class="param">
462
+
463
+ <li>
464
+
465
+ <span class='name'>format</span>
466
+
467
+
468
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>)</span>
469
+
470
+
471
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
472
+
473
+
474
+ &mdash;
475
+ <div class='inline'><p>The format to use for formatting.</p>
476
+ </div>
477
+
478
+ </li>
479
+
480
+ </ul>
481
+
482
+ <p class="tag_title">Returns:</p>
483
+ <ul class="return">
484
+
485
+ <li>
486
+
487
+
488
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>)</span>
489
+
490
+
491
+
492
+ &mdash;
493
+ <div class='inline'><p>The formatted date.</p>
494
+ </div>
495
+
496
+ </li>
497
+
498
+ </ul>
499
+
500
+ </div><table class="source_code">
501
+ <tr>
502
+ <td>
503
+ <pre class="lines">
504
+
505
+
506
+ 246
507
+ 247
508
+ 248</pre>
509
+ </td>
510
+ <td>
511
+ <pre class="code"><span class="info file"># File 'lib/cowtech-extensions/datetime.rb', line 246</span>
512
+
513
+ <span class='kw'>def</span> <span class='id identifier rubyid_local_strftime'>local_strftime</span><span class='lparen'>(</span><span class='id identifier rubyid_format'>format</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
514
+ <span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:in_time_zone</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_in_time_zone'>in_time_zone</span> <span class='op'>:</span> <span class='kw'>self</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_strftime'>strftime</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_custom_format'>custom_format</span><span class='lparen'>(</span><span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span><span class='rparen'>)</span>
515
+ <span class='kw'>end</span></pre>
516
+ </td>
517
+ </tr>
518
+ </table>
519
+ </div>
520
+
521
+ <div class="method_details ">
522
+ <h3 class="signature " id="lstrftime-instance_method">
523
+
524
+ - (<tt><span class='object_link'><a href="String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>) <strong>lstrftime</strong>(format = nil)
525
+
526
+
527
+
528
+
529
+
530
+ </h3><div class="docstring">
531
+ <div class="discussion">
532
+ <p>Formats a datetime, looking up also custom formats.</p>
533
+
534
+
535
+ </div>
536
+ </div>
537
+ <div class="tags">
538
+ <p class="tag_title">Parameters:</p>
539
+ <ul class="param">
540
+
541
+ <li>
542
+
543
+ <span class='name'>format</span>
544
+
545
+
546
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>)</span>
547
+
548
+
549
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
550
+
551
+
552
+ &mdash;
553
+ <div class='inline'><p>A format or a custom format name to use for formatting.</p>
554
+ </div>
555
+
556
+ </li>
557
+
558
+ </ul>
559
+
560
+ <p class="tag_title">Returns:</p>
561
+ <ul class="return">
562
+
563
+ <li>
564
+
565
+
566
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>)</span>
567
+
568
+
569
+
570
+ &mdash;
571
+ <div class='inline'><p>The formatted date.</p>
572
+ </div>
573
+
574
+ </li>
575
+
576
+ </ul>
577
+
578
+ <p class="tag_title">See Also:</p>
579
+ <ul class="see">
580
+
581
+ <li><span class='object_link'><a href="Settings.html#setup_date_formats-instance_method" title="Cowtech::Extensions::Settings#setup_date_formats (method)">Settings#setup_date_formats</a></span></li>
582
+
583
+ </ul>
584
+
585
+ </div><table class="source_code">
586
+ <tr>
587
+ <td>
588
+ <pre class="lines">
589
+
590
+
591
+ 211
592
+ 212
593
+ 213
594
+ 214
595
+ 215
596
+ 216
597
+ 217
598
+ 218
599
+ 219
600
+ 220
601
+ 221
602
+ 222
603
+ 223
604
+ 224
605
+ 225
606
+ 226
607
+ 227
608
+ 228
609
+ 229
610
+ 230
611
+ 231
612
+ 232
613
+ 233
614
+ 234
615
+ 235
616
+ 236
617
+ 237
618
+ 238
619
+ 239
620
+ 240</pre>
621
+ </td>
622
+ <td>
623
+ <pre class="code"><span class="info file"># File 'lib/cowtech-extensions/datetime.rb', line 211</span>
624
+
625
+ <span class='kw'>def</span> <span class='id identifier rubyid_lstrftime'>lstrftime</span><span class='lparen'>(</span><span class='id identifier rubyid_format'>format</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
626
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='kw'>nil</span>
627
+ <span class='id identifier rubyid_names'>names</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>Cowtech</span><span class='op'>::</span><span class='const'>Extensions</span><span class='period'>.</span><span class='id identifier rubyid_settings'>settings</span><span class='period'>.</span><span class='id identifier rubyid_date_names'>date_names</span>
628
+
629
+ <span class='id identifier rubyid_final_format'>final_format</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_custom_format'>custom_format</span><span class='lparen'>(</span><span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</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'>(%{1,2}:?[abz])</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_match'>match</span><span class='op'>|</span>
630
+ <span class='id identifier rubyid_mrv'>mrv</span> <span class='op'>=</span> <span class='id identifier rubyid_match'>match</span>
631
+
632
+ <span class='comment'># Handling of %z is to fix ruby 1.8 bug in OSX: http://bugs.ruby-lang.org/issues/2396
633
+ </span> <span class='kw'>if</span> <span class='id identifier rubyid_match'>match</span> <span class='op'>!~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^%%</span><span class='regexp_end'>/</span></span> <span class='kw'>then</span>
634
+ <span class='kw'>case</span> <span class='id identifier rubyid_match'>match</span>
635
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%a</span><span class='tstring_end'>&quot;</span></span>
636
+ <span class='id identifier rubyid_mrv'>mrv</span> <span class='op'>=</span> <span class='id identifier rubyid_names'>names</span><span class='lbracket'>[</span><span class='symbol'>:short_days</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_wday'>wday</span><span class='rbracket'>]</span>
637
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%A</span><span class='tstring_end'>&quot;</span></span>
638
+ <span class='id identifier rubyid_mrv'>mrv</span> <span class='op'>=</span> <span class='id identifier rubyid_names'>names</span><span class='lbracket'>[</span><span class='symbol'>:long_days</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_wday'>wday</span><span class='rbracket'>]</span>
639
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%b</span><span class='tstring_end'>&quot;</span></span>
640
+ <span class='id identifier rubyid_mrv'>mrv</span> <span class='op'>=</span> <span class='id identifier rubyid_names'>names</span><span class='lbracket'>[</span><span class='symbol'>:short_months</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_month'>month</span> <span class='op'>-</span> <span class='int'>1</span><span class='rbracket'>]</span>
641
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%B</span><span class='tstring_end'>&quot;</span></span>
642
+ <span class='id identifier rubyid_mrv'>mrv</span> <span class='op'>=</span> <span class='id identifier rubyid_names'>names</span><span class='lbracket'>[</span><span class='symbol'>:long_months</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_month'>month</span> <span class='op'>-</span> <span class='int'>1</span><span class='rbracket'>]</span>
643
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%z</span><span class='tstring_end'>&quot;</span></span>
644
+ <span class='id identifier rubyid_mrv'>mrv</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>Cowtech</span><span class='op'>::</span><span class='const'>Extensions</span><span class='period'>.</span><span class='id identifier rubyid_is_ruby_18?'>is_ruby_18?</span> <span class='op'>?</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_formatted_offset'>formatted_offset</span><span class='lparen'>(</span><span class='kw'>false</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
645
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%:z</span><span class='tstring_end'>&quot;</span></span>
646
+ <span class='id identifier rubyid_mrv'>mrv</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>Cowtech</span><span class='op'>::</span><span class='const'>Extensions</span><span class='period'>.</span><span class='id identifier rubyid_is_ruby_18?'>is_ruby_18?</span> <span class='op'>?</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_formatted_offset'>formatted_offset</span><span class='lparen'>(</span><span class='kw'>true</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
647
+ <span class='kw'>end</span>
648
+ <span class='kw'>end</span>
649
+
650
+ <span class='id identifier rubyid_mrv'>mrv</span> <span class='op'>?</span> <span class='id identifier rubyid_mrv'>mrv</span><span class='period'>.</span><span class='id identifier rubyid_sub'>sub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%%</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_match'>match</span>
651
+ <span class='kw'>end</span>
652
+
653
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_strftime'>strftime</span><span class='lparen'>(</span><span class='id identifier rubyid_final_format'>final_format</span><span class='rparen'>)</span>
654
+ <span class='kw'>end</span></pre>
655
+ </td>
656
+ </tr>
657
+ </table>
658
+ </div>
659
+
660
+ <div class="method_details ">
661
+ <h3 class="signature " id="padded_month-instance_method">
662
+
663
+ - (<tt><span class='object_link'><a href="String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>) <strong>padded_month</strong>
664
+
665
+
666
+
667
+
668
+
669
+ </h3><div class="docstring">
670
+ <div class="discussion">
671
+ <p>Returns the current month number with leading 0.</p>
672
+
673
+
674
+ </div>
675
+ </div>
676
+ <div class="tags">
677
+
678
+ <p class="tag_title">Returns:</p>
679
+ <ul class="return">
680
+
681
+ <li>
682
+
683
+
684
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="Cowtech::Extensions::String (module)">String</a></span></tt>)</span>
685
+
686
+
687
+
688
+ &mdash;
689
+ <div class='inline'><p>The current month number with leading 0.</p>
690
+ </div>
691
+
692
+ </li>
693
+
694
+ </ul>
695
+
696
+ </div><table class="source_code">
697
+ <tr>
698
+ <td>
699
+ <pre class="lines">
700
+
701
+
702
+ 202
703
+ 203
704
+ 204</pre>
705
+ </td>
706
+ <td>
707
+ <pre class="code"><span class="info file"># File 'lib/cowtech-extensions/datetime.rb', line 202</span>
708
+
709
+ <span class='kw'>def</span> <span class='id identifier rubyid_padded_month'>padded_month</span>
710
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_month'>month</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_rjust'>rjust</span><span class='lparen'>(</span><span class='int'>2</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
711
+ <span class='kw'>end</span></pre>
712
+ </td>
713
+ </tr>
714
+ </table>
715
+ </div>
716
+
717
+ <div class="method_details ">
718
+ <h3 class="signature " id="utc_time-instance_method">
719
+
720
+ - (<tt>UTC::Time</tt>) <strong>utc_time</strong>
721
+
722
+
723
+
724
+
725
+
726
+ </h3><div class="docstring">
727
+ <div class="discussion">
728
+ <p>Returns the UTC::Time representation of the current datetime.</p>
729
+
730
+
731
+ </div>
732
+ </div>
733
+ <div class="tags">
734
+
735
+ <p class="tag_title">Returns:</p>
736
+ <ul class="return">
737
+
738
+ <li>
739
+
740
+
741
+ <span class='type'>(<tt>UTC::Time</tt>)</span>
742
+
743
+
744
+
745
+ &mdash;
746
+ <div class='inline'><p>The UTC::Time representation of the current datetime.</p>
747
+ </div>
748
+
749
+ </li>
750
+
751
+ </ul>
752
+
753
+ </div><table class="source_code">
754
+ <tr>
755
+ <td>
756
+ <pre class="lines">
757
+
758
+
759
+ 180
760
+ 181
761
+ 182
762
+ 183</pre>
763
+ </td>
764
+ <td>
765
+ <pre class="code"><span class="info file"># File 'lib/cowtech-extensions/datetime.rb', line 180</span>
766
+
767
+ <span class='kw'>def</span> <span class='id identifier rubyid_utc_time'>utc_time</span>
768
+ <span class='id identifier rubyid_ua'>ua</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:utc</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='kw'>self</span> <span class='op'>:</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_utc'>utc</span>
769
+ <span class='op'>::</span><span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_utc'>utc</span><span class='lparen'>(</span><span class='id identifier rubyid_ua'>ua</span><span class='period'>.</span><span class='id identifier rubyid_year'>year</span><span class='comma'>,</span> <span class='id identifier rubyid_ua'>ua</span><span class='period'>.</span><span class='id identifier rubyid_month'>month</span><span class='comma'>,</span> <span class='id identifier rubyid_ua'>ua</span><span class='period'>.</span><span class='id identifier rubyid_day'>day</span><span class='comma'>,</span> <span class='id identifier rubyid_ua'>ua</span><span class='period'>.</span><span class='id identifier rubyid_hour'>hour</span><span class='comma'>,</span> <span class='id identifier rubyid_ua'>ua</span><span class='period'>.</span><span class='id identifier rubyid_min'>min</span><span class='comma'>,</span> <span class='id identifier rubyid_ua'>ua</span><span class='period'>.</span><span class='id identifier rubyid_sec'>sec</span><span class='rparen'>)</span>
770
+ <span class='kw'>end</span></pre>
771
+ </td>
772
+ </tr>
773
+ </table>
774
+ </div>
775
+
776
+ </div>
777
+
778
+ </div>
779
+
780
+ <div id="footer">
781
+ Generated on Thu Jul 19 17:17:50 2012 by
782
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
783
+ 0.8.2.1 (ruby-1.9.2).
784
+ </div>
785
+
786
+ </body>
787
+ </html>