facets 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.rdoc +331 -35
- data/MANIFEST +685 -826
- data/{doc/guide/notes.rd → NOTES} +0 -0
- data/README.rdoc +73 -25
- data/Rakefile +245 -2
- data/TODO +5 -0
- data/demo/hook.rd +47 -0
- data/demo/scenario_require.rd +9 -0
- data/doc/README.more +24 -6
- data/doc/manual/about.rb +47 -0
- data/doc/manual/annotations.rdoc +60 -0
- data/doc/manual/associations.rdoc +55 -0
- data/doc/manual/blockups.rdoc +101 -0
- data/doc/manual/capsule.rdoc +34 -0
- data/doc/manual/command.rdoc +177 -0
- data/doc/manual/core.rdoc +37 -0
- data/doc/manual/faq.rdoc +32 -0
- data/doc/manual/typecast.html +112 -0
- data/lib/core/facets.rb +359 -11
- data/lib/core/facets/array/combination.rb +3 -3
- data/lib/core/facets/array/index.rb +4 -1
- data/lib/core/facets/array/permutation.rb +2 -2
- data/lib/core/facets/array/product.rb +1 -1
- data/lib/core/facets/binding/eval.rb +1 -1
- data/lib/core/facets/denumerable.rb +76 -0
- data/lib/core/facets/duplicable.rb +34 -0
- data/lib/core/facets/enumerable/count.rb +10 -4
- data/lib/core/facets/enumerable/defer.rb +77 -0
- data/lib/core/facets/enumerable/each_by.rb +1 -1
- data/lib/core/facets/enumerable/every.rb +35 -0
- data/lib/{more/facets/elementwise.rb → core/facets/enumerable/ewise.rb} +0 -0
- data/lib/core/facets/enumerable/filter.rb +25 -0
- data/lib/core/facets/enumerable/group_by.rb +1 -1
- data/lib/core/facets/enumerable/none.rb +3 -2
- data/lib/core/facets/enumerable/one.rb +3 -2
- data/lib/core/facets/enumerable/per.rb +61 -0
- data/lib/core/facets/exception/raised.rb +14 -0
- data/lib/core/facets/integer/odd.rb +5 -1
- data/lib/core/facets/kernel/__dir__.rb +13 -3
- data/lib/core/facets/kernel/__here__.rb +14 -0
- data/lib/core/facets/kernel/__method__.rb +9 -3
- data/lib/core/facets/kernel/ask.rb +1 -0
- data/lib/core/facets/kernel/equate.rb +13 -0
- data/lib/core/facets/kernel/extension.rb +9 -0
- data/lib/core/facets/kernel/identical.rb +4 -0
- data/lib/core/facets/kernel/instance_exec.rb +2 -1
- data/lib/core/facets/kernel/method.rb +49 -0
- data/lib/core/facets/kernel/object_send.rb +2 -2
- data/lib/core/facets/kernel/{state.rb → object_state.rb} +23 -12
- data/lib/core/facets/kernel/require_all.rb +6 -1
- data/lib/core/facets/kernel/require_local.rb +8 -1
- data/lib/core/facets/kernel/require_relative.rb +52 -0
- data/lib/core/facets/kernel/source_location.rb +13 -0
- data/lib/core/facets/kernel/tap.rb +13 -6
- data/lib/core/facets/module/attr_setter.rb +57 -0
- data/lib/core/facets/module/instance_method.rb +24 -0
- data/lib/core/facets/module/module_load.rb +60 -44
- data/lib/core/facets/module/module_require.rb +1 -0
- data/lib/core/facets/nilclass/to_f.rb +1 -1
- data/lib/core/facets/objectspace/op_fetch.rb +3 -0
- data/lib/core/facets/proc/curry.rb +4 -3
- data/lib/core/facets/string/bytes.rb +10 -4
- data/lib/core/facets/string/camelcase.rb +6 -5
- data/lib/core/facets/string/chars.rb +5 -1
- data/lib/core/facets/string/each_char.rb +1 -1
- data/lib/core/facets/string/each_word.rb +1 -1
- data/lib/core/facets/string/lines.rb +11 -4
- data/lib/core/facets/string/start_with.rb +9 -2
- data/lib/core/facets/string/unfold.rb +27 -0
- data/lib/core/facets/symbol/succ.rb +3 -3
- data/lib/core/facets/symbol/thrown.rb +20 -0
- data/lib/core/facets/symbol/to_proc.rb +3 -2
- data/lib/core/facets/time/to_time.rb +1 -1
- data/lib/core/facets/to_hash.rb +41 -100
- data/lib/core/facets/unboundmethod/name.rb +20 -23
- data/lib/more/facets/ansicode.rb +1 -10
- data/lib/more/facets/autoarray.rb +3 -31
- data/lib/more/facets/basicobject.rb +73 -0
- data/lib/more/facets/blankslate.rb +2 -66
- data/lib/{lore → more}/facets/cgi.rb +0 -0
- data/lib/more/facets/class_extend.rb +1 -0
- data/lib/{lore → more}/facets/continuation.rb +0 -0
- data/lib/{lore → more}/facets/date.rb +3 -3
- data/lib/more/facets/enumargs.rb +192 -0
- data/lib/more/facets/enumerablepass.rb +2 -216
- data/lib/more/facets/enumerator.rb +62 -0
- data/lib/more/facets/{equatable.rb → equitable.rb} +11 -11
- data/lib/more/facets/expirable.rb +13 -41
- data/lib/{lore → more}/facets/fileutils.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/head.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/safe_ln.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/slice.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/tail.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/wc.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/whereis.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/which.rb +0 -0
- data/lib/{lore → more}/facets/getoptlong.rb +0 -0
- data/lib/more/facets/hook.rb +2 -29
- data/lib/more/facets/inheritor.rb +2 -2
- data/lib/more/facets/instance_eval.rb +50 -0
- data/lib/more/facets/instance_function.rb +78 -0
- data/lib/more/facets/main.rb +20 -15
- data/lib/more/facets/memoize.rb +1 -113
- data/lib/more/facets/module/attr.rb +83 -0
- data/lib/more/facets/module/attr_tester.rb +44 -0
- data/lib/more/facets/module/attr_toggler.rb +59 -0
- data/lib/more/facets/module/attr_validator.rb +34 -0
- data/lib/more/facets/{class_extension.rb → module/class_extend.rb} +21 -13
- data/lib/more/facets/once.rb +59 -0
- data/lib/more/facets/openmodule.rb +1 -0
- data/lib/more/facets/orderedhash.rb +1 -33
- data/lib/{lore → more}/facets/ostruct.rb +0 -0
- data/lib/more/facets/ostructable.rb +1 -4
- data/lib/more/facets/partial.rb +18 -16
- data/lib/{lore → more}/facets/pathname.rb +0 -0
- data/lib/more/facets/preinitialize.rb +157 -0
- data/lib/{lore → more}/facets/rbconfig.rb +0 -0
- data/lib/more/facets/recorder.rb +1 -2
- data/lib/{lore → more}/facets/set.rb +0 -0
- data/lib/{lore → more}/facets/shellwords.rb +0 -0
- data/lib/{lore → more}/facets/uri.rb +0 -0
- data/lib/{lore → more}/facets/yaml.rb +0 -0
- data/lib/{lore → more}/facets/zlib.rb +0 -0
- data/meta/loadpath +0 -1
- data/meta/sitemap +4 -0
- data/meta/version +1 -1
- data/test/core/enumerable/test_count.rb +1 -1
- data/test/{more/test_filter.rb → core/enumerable/test_defer.rb} +24 -22
- data/test/{more/test_elementor.rb → core/enumerable/test_every.rb} +2 -15
- data/test/core/enumerable/test_ewise.rb +23 -0
- data/test/core/enumerable/test_per.rb +18 -0
- data/test/core/enumerable/test_take.rb +13 -0
- data/test/core/kernel/test_deepcopy.rb +1 -1
- data/test/{more/test_1stclassmethod.rb → core/kernel/test_method.rb} +2 -7
- data/test/core/kernel/test_tap.rb +1 -1
- data/test/core/proc/test_curry.rb +11 -0
- data/test/core/string/test_bytes.rb +1 -1
- data/test/core/string/test_camelcase.rb +23 -6
- data/test/core/string/test_lines.rb +1 -1
- data/test/core/string/test_unfold.rb +14 -0
- data/test/{more → core}/test_blank.rb +0 -0
- data/test/{more → core}/test_boolean.rb +0 -0
- data/test/{more → core}/test_functor.rb +0 -0
- data/test/{lore → more}/test_basicobject.rb +0 -0
- data/test/more/{test_class_extension.rb → test_class_extend.rb} +6 -6
- data/test/{lore → more}/test_continuation.rb +0 -0
- data/test/{lore → more}/test_date.rb +0 -0
- data/test/more/{test_enumerablepass.rb → test_enumargs.rb} +2 -4
- data/test/more/{test_equatable.rb → test_equitable.rb} +2 -2
- data/test/more/{test_instantise.rb → test_instance_function.rb} +3 -2
- data/test/more/test_memoize.rb +1 -1
- data/test/{lore → more}/test_ostruct.rb +0 -0
- metadata +865 -1016
- data/RELEASE +0 -38
- data/doc/README.lore +0 -51
- data/doc/log/basic_stats/index.html +0 -39
- data/doc/log/changelog.html +0 -648
- data/doc/log/changelog.txt +0 -217
- data/doc/log/stats/index.html +0 -39
- data/doc/log/testlog.txt +0 -278
- data/doc/notes/CHANGES +0 -2529
- data/doc/rdoc/lore/classes/Array.html +0 -176
- data/doc/rdoc/lore/classes/CGI.html +0 -191
- data/doc/rdoc/lore/classes/Config.html +0 -135
- data/doc/rdoc/lore/classes/Continuation.html +0 -113
- data/doc/rdoc/lore/classes/Date.html +0 -631
- data/doc/rdoc/lore/classes/DateTime.html +0 -583
- data/doc/rdoc/lore/classes/Enumerable.html +0 -89
- data/doc/rdoc/lore/classes/Enumerable/Enumerator.html +0 -147
- data/doc/rdoc/lore/classes/File.html +0 -128
- data/doc/rdoc/lore/classes/FileUtils.html +0 -434
- data/doc/rdoc/lore/classes/GetoptLong.html +0 -118
- data/doc/rdoc/lore/classes/GetoptLong/DSL.html +0 -208
- data/doc/rdoc/lore/classes/Kernel.html +0 -135
- data/doc/rdoc/lore/classes/Logger.html +0 -229
- data/doc/rdoc/lore/classes/Logger/Ansicolor.html +0 -277
- data/doc/rdoc/lore/classes/Logger/LogDevice.html +0 -121
- data/doc/rdoc/lore/classes/NilClass.html +0 -119
- data/doc/rdoc/lore/classes/OpenStruct.html +0 -432
- data/doc/rdoc/lore/classes/Pathname.html +0 -353
- data/doc/rdoc/lore/classes/Set.html +0 -117
- data/doc/rdoc/lore/classes/Shellwords.html +0 -111
- data/doc/rdoc/lore/classes/String.html +0 -140
- data/doc/rdoc/lore/classes/Time.html +0 -154
- data/doc/rdoc/lore/classes/URI.html +0 -454
- data/doc/rdoc/lore/classes/URI/Hash.html +0 -105
- data/doc/rdoc/lore/classes/URI/Kernel.html +0 -122
- data/doc/rdoc/lore/classes/Zlib.html +0 -188
- data/doc/rdoc/lore/created.rid +0 -1
- data/doc/rdoc/lore/files/README.html +0 -286
- data/doc/rdoc/lore/files/doc/README_lore.html +0 -155
- data/doc/rdoc/lore/files/lib/lore/facets/basicobject_rb.html +0 -118
- data/doc/rdoc/lore/files/lib/lore/facets/cgi_rb.html +0 -111
- data/doc/rdoc/lore/files/lib/lore/facets/continuation_rb.html +0 -147
- data/doc/rdoc/lore/files/lib/lore/facets/date_rb.html +0 -97
- data/doc/rdoc/lore/files/lib/lore/facets/enumerator_rb.html +0 -111
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/head_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/safe_ln_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/slice_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/tail_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/wc_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/whereis_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/which_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils_rb.html +0 -131
- data/doc/rdoc/lore/files/lib/lore/facets/getoptlong_rb.html +0 -135
- data/doc/rdoc/lore/files/lib/lore/facets/logger_rb.html +0 -142
- data/doc/rdoc/lore/files/lib/lore/facets/ostruct_rb.html +0 -135
- data/doc/rdoc/lore/files/lib/lore/facets/pathname_rb.html +0 -145
- data/doc/rdoc/lore/files/lib/lore/facets/rbconfig_rb.html +0 -124
- data/doc/rdoc/lore/files/lib/lore/facets/set_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/shellwords_rb.html +0 -124
- data/doc/rdoc/lore/files/lib/lore/facets/uri_rb.html +0 -125
- data/doc/rdoc/lore/files/lib/lore/facets/yaml_rb.html +0 -146
- data/doc/rdoc/lore/files/lib/lore/facets/zlib_rb.html +0 -97
- data/doc/rdoc/lore/fr_class_index.html +0 -73
- data/doc/rdoc/lore/fr_file_index.html +0 -71
- data/doc/rdoc/lore/fr_method_index.html +0 -177
- data/doc/rdoc/lore/index.html +0 -26
- data/doc/rdoc/lore/rdoc-style.css +0 -177
- data/doc/release-notes/RELEASE-2.0.5 +0 -8
- data/doc/release-notes/RELEASE-2.1.0 +0 -9
- data/doc/release-notes/RELEASE-2.1.1 +0 -5
- data/doc/release-notes/RELEASE-2.1.2 +0 -6
- data/doc/release-notes/RELEASE-2.1.3 +0 -5
- data/doc/release-notes/RELEASE-2.2.0 +0 -14
- data/doc/release-notes/RELEASE-2.2.1 +0 -4
- data/doc/release-notes/RELEASE-2.3.0 +0 -6
- data/doc/release-notes/RELEASE-2.4.0 +0 -70
- data/doc/release-notes/RELEASE-2.4.1 +0 -8
- data/doc/release-notes/RELEASE-2.4.2 +0 -4
- data/doc/release-notes/RELEASE-2.4.3 +0 -78
- data/doc/release-notes/RELEASE-2.4.4 +0 -38
- data/doc/release-notes/RELEASE-2.4.5 +0 -37
- data/doc/release-notes/RELEASE-2.5.0 +0 -83
- data/lib/core/facets/kernel/instance.rb +0 -19
- data/lib/lore/facets/basicobject.rb +0 -14
- data/lib/lore/facets/enumerator.rb +0 -67
- data/lib/lore/facets/logger.rb +0 -291
- data/lib/more/facets/1stclassmethod.rb +0 -140
- data/lib/more/facets/advisable.rb +0 -162
- data/lib/more/facets/association.rb +0 -210
- data/lib/more/facets/attr.rb +0 -209
- data/lib/more/facets/basex.rb +0 -37
- data/lib/more/facets/bbcode.rb +0 -397
- data/lib/more/facets/bicrypt.rb +0 -265
- data/lib/more/facets/binreadable.rb +0 -221
- data/lib/more/facets/censor.rb +0 -97
- data/lib/more/facets/classmethods.rb +0 -199
- data/lib/more/facets/consoleutils.rb +0 -99
- data/lib/more/facets/crypt.rb +0 -166
- data/lib/more/facets/dependency.rb +0 -151
- data/lib/more/facets/downloader.rb +0 -281
- data/lib/more/facets/duplicable.rb +0 -43
- data/lib/more/facets/elementor.rb +0 -133
- data/lib/more/facets/filter.rb +0 -121
- data/lib/more/facets/heap.rb +0 -22
- data/lib/more/facets/infinity.rb +0 -193
- data/lib/more/facets/ini.rb +0 -264
- data/lib/more/facets/instantise.rb +0 -1
- data/lib/more/facets/instantize.rb +0 -95
- data/lib/more/facets/interval.rb +0 -282
- data/lib/more/facets/iteration.rb +0 -65
- data/lib/more/facets/linkedlist.rb +0 -222
- data/lib/more/facets/lrucache.rb +0 -157
- data/lib/more/facets/matcher.rb +0 -140
- data/lib/more/facets/memoizer.rb +0 -74
- data/lib/more/facets/minitar.rb +0 -1063
- data/lib/more/facets/nackclass.rb +0 -41
- data/lib/more/facets/net/smtp_tls.rb +0 -131
- data/lib/more/facets/nilstatus.rb +0 -48
- data/lib/more/facets/overload.rb +0 -94
- data/lib/more/facets/paramix.rb +0 -202
- data/lib/more/facets/pool.rb +0 -91
- data/lib/more/facets/pqueue.rb +0 -449
- data/lib/more/facets/pry.rb +0 -32
- data/lib/more/facets/reflection.rb +0 -145
- data/lib/more/facets/semaphore.rb +0 -92
- data/lib/more/facets/settings.rb +0 -248
- data/lib/more/facets/snapshot.rb +0 -209
- data/lib/more/facets/sparse_array.rb +0 -809
- data/lib/more/facets/string/mask.rb +0 -278
- data/lib/more/facets/string/obfuscate.rb +0 -65
- data/lib/more/facets/string/stylize.rb +0 -169
- data/lib/more/facets/string/words.rb +0 -167
- data/lib/more/facets/syncarray.rb +0 -114
- data/lib/more/facets/synchash.rb +0 -157
- data/lib/more/facets/typecast.rb +0 -261
- data/lib/more/facets/uninheritable.rb +0 -50
- data/lib/more/facets/xmlhash.rb +0 -112
- data/lib/more/facets/xoxo.rb +0 -259
- data/lib/more/facets/ziputils.rb +0 -490
- data/task/conflicts +0 -63
- data/task/coverage.rake +0 -37
- data/task/methods +0 -49
- data/task/rdoc.rake +0 -17
- data/task/setup.rake +0 -38
- data/task/test.rake +0 -145
- data/test/more/test_advisable.rb +0 -71
- data/test/more/test_association.rb +0 -38
- data/test/more/test_bbcode.rb +0 -21
- data/test/more/test_binreadable.rb +0 -50
- data/test/more/test_buildable.rb +0 -73
- data/test/more/test_classmethods.rb +0 -56
- data/test/more/test_crypt.rb +0 -32
- data/test/more/test_dependency.rb +0 -69
- data/test/more/test_elementwise.rb +0 -25
- data/test/more/test_infinity.rb +0 -40
- data/test/more/test_interval.rb +0 -151
- data/test/more/test_linkedlist.rb +0 -41
- data/test/more/test_lrucache.rb +0 -14
- data/test/more/test_overload.rb +0 -160
- data/test/more/test_paramix.rb +0 -170
- data/test/more/test_prototype.rb +0 -35
- data/test/more/test_snapshot.rb +0 -21
- data/test/more/test_sparsearray.rb +0 -279
- data/test/more/test_syncarray.rb +0 -15
- data/test/more/test_synchash.rb +0 -16
- data/test/more/test_typecast.rb +0 -54
- data/test/more/test_uninheritable.rb +0 -31
- data/test/more/test_xoxo.rb +0 -274
- data/test/test_facets.rb +0 -9
@@ -1,113 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
<html>
|
6
|
-
<head>
|
7
|
-
<title>Class: Continuation</title>
|
8
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
9
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
10
|
-
|
11
|
-
<script language="JavaScript" type="text/javascript">
|
12
|
-
// <![CDATA[
|
13
|
-
|
14
|
-
function toggleSource( id )
|
15
|
-
{
|
16
|
-
var elem
|
17
|
-
var link
|
18
|
-
|
19
|
-
if( document.getElementById )
|
20
|
-
{
|
21
|
-
elem = document.getElementById( id )
|
22
|
-
link = document.getElementById( "l_" + id )
|
23
|
-
}
|
24
|
-
else if ( document.all )
|
25
|
-
{
|
26
|
-
elem = eval( "document.all." + id )
|
27
|
-
link = eval( "document.all.l_" + id )
|
28
|
-
}
|
29
|
-
else
|
30
|
-
return false;
|
31
|
-
|
32
|
-
if( elem.style.display == "block" )
|
33
|
-
{
|
34
|
-
elem.style.display = "none"
|
35
|
-
link.innerHTML = "+"
|
36
|
-
}
|
37
|
-
else
|
38
|
-
{
|
39
|
-
elem.style.display = "block"
|
40
|
-
link.innerHTML = "-"
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
function openCode( url )
|
45
|
-
{
|
46
|
-
window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus();
|
47
|
-
}
|
48
|
-
// ]]>
|
49
|
-
</script>
|
50
|
-
</head>
|
51
|
-
|
52
|
-
<body>
|
53
|
-
<table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
|
54
|
-
<td class="file-title"><span class="file-title-prefix">Class</span><br />Continuation</td>
|
55
|
-
<td align="right">
|
56
|
-
<table cellspacing="0" cellpadding="2">
|
57
|
-
<tr valign="top">
|
58
|
-
<td>In:</td>
|
59
|
-
<td>
|
60
|
-
</td>
|
61
|
-
</tr>
|
62
|
-
<tr>
|
63
|
-
<td>Parent:</td>
|
64
|
-
<td>
|
65
|
-
Object
|
66
|
-
</td>
|
67
|
-
</tr>
|
68
|
-
</table>
|
69
|
-
</td>
|
70
|
-
</tr>
|
71
|
-
</table>
|
72
|
-
<!-- banner header -->
|
73
|
-
|
74
|
-
<div id="bodyContent">
|
75
|
-
<div id="content">
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
<div class="sectiontitle">Methods</div>
|
81
|
-
<span style="padding-right: 5px;"><a href="#M000008">create</a></span>
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
<div class="sectiontitle">Public Class methods</div>
|
89
|
-
<div class="method">
|
90
|
-
<div class="title">
|
91
|
-
<a name="M000008"></a><b>create</b>(*args, &block)
|
92
|
-
</div>
|
93
|
-
<div class="sourcecode">
|
94
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000008_source')" id="l_M000008_source">+</a> ]</p>
|
95
|
-
<div id="M000008_source" class="dyn-source">
|
96
|
-
<pre>
|
97
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/continuation.rb, line 52</span>
|
98
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">Continuation</span>.<span class="ruby-identifier">create</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
99
|
-
<span class="ruby-identifier">args</span> = [<span class="ruby-identifier">args</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">and</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Array</span> <span class="ruby-comment cmt"># 1.6.8 compatibility</span>
|
100
|
-
<span class="ruby-identifier">cc</span> = <span class="ruby-keyword kw">nil</span>; <span class="ruby-identifier">result</span> = <span class="ruby-identifier">callcc</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">cc</span> = <span class="ruby-identifier">c</span>; <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">cc</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>}
|
101
|
-
<span class="ruby-identifier">result</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">args</span>
|
102
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-operator">*</span>[<span class="ruby-identifier">cc</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">result</span>]
|
103
|
-
<span class="ruby-keyword kw">end</span>
|
104
|
-
</pre>
|
105
|
-
</div>
|
106
|
-
</div>
|
107
|
-
</div>
|
108
|
-
</div>
|
109
|
-
|
110
|
-
</div>
|
111
|
-
|
112
|
-
</body>
|
113
|
-
</html>
|
@@ -1,631 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
<html>
|
6
|
-
<head>
|
7
|
-
<title>Class: Date</title>
|
8
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
9
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
10
|
-
|
11
|
-
<script language="JavaScript" type="text/javascript">
|
12
|
-
// <![CDATA[
|
13
|
-
|
14
|
-
function toggleSource( id )
|
15
|
-
{
|
16
|
-
var elem
|
17
|
-
var link
|
18
|
-
|
19
|
-
if( document.getElementById )
|
20
|
-
{
|
21
|
-
elem = document.getElementById( id )
|
22
|
-
link = document.getElementById( "l_" + id )
|
23
|
-
}
|
24
|
-
else if ( document.all )
|
25
|
-
{
|
26
|
-
elem = eval( "document.all." + id )
|
27
|
-
link = eval( "document.all.l_" + id )
|
28
|
-
}
|
29
|
-
else
|
30
|
-
return false;
|
31
|
-
|
32
|
-
if( elem.style.display == "block" )
|
33
|
-
{
|
34
|
-
elem.style.display = "none"
|
35
|
-
link.innerHTML = "+"
|
36
|
-
}
|
37
|
-
else
|
38
|
-
{
|
39
|
-
elem.style.display = "block"
|
40
|
-
link.innerHTML = "-"
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
function openCode( url )
|
45
|
-
{
|
46
|
-
window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus();
|
47
|
-
}
|
48
|
-
// ]]>
|
49
|
-
</script>
|
50
|
-
</head>
|
51
|
-
|
52
|
-
<body>
|
53
|
-
<table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
|
54
|
-
<td class="file-title"><span class="file-title-prefix">Class</span><br />Date</td>
|
55
|
-
<td align="right">
|
56
|
-
<table cellspacing="0" cellpadding="2">
|
57
|
-
<tr valign="top">
|
58
|
-
<td>In:</td>
|
59
|
-
<td>
|
60
|
-
<a href="../files/lib/lore/facets/date_rb.html">lib/lore/facets/date.rb</a>
|
61
|
-
</td>
|
62
|
-
</tr>
|
63
|
-
<tr>
|
64
|
-
<td>Parent:</td>
|
65
|
-
<td>
|
66
|
-
Object
|
67
|
-
</td>
|
68
|
-
</tr>
|
69
|
-
</table>
|
70
|
-
</td>
|
71
|
-
</tr>
|
72
|
-
</table>
|
73
|
-
<!-- banner header -->
|
74
|
-
|
75
|
-
<div id="bodyContent">
|
76
|
-
<div id="content">
|
77
|
-
|
78
|
-
<div class="description"><h1><a href="Date.html">Date</a></h1>
|
79
|
-
<p>
|
80
|
-
This new version of <a href="Date.html">Date</a> extension has been largely
|
81
|
-
improved by porting some of the methods used by ActiveSupport. The old
|
82
|
-
version already had much <a href="Date.html#M000035">in</a> common with the
|
83
|
-
Active Support library, so it was decided to take it a step further <a
|
84
|
-
href="Date.html#M000035">in</a> that direction for the sake of
|
85
|
-
interoparability.
|
86
|
-
</p>
|
87
|
-
<p>
|
88
|
-
Hopefully most of these methods will find there way into Ruby‘s own
|
89
|
-
standard library eventually.
|
90
|
-
</p>
|
91
|
-
<p>
|
92
|
-
The biggest difference with ActiveSupport is the lack of many of the
|
93
|
-
"English-esque" methods, and that we use <a
|
94
|
-
href="Date.html#M000030">stamp</a> with Date::FORMAT, instead of
|
95
|
-
to_formmated_s with Date::DATE_FORMATS. We do not override the standard
|
96
|
-
to_s method like ActiveSupport does.
|
97
|
-
</p>
|
98
|
-
</div>
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
<div class="sectiontitle">Methods</div>
|
103
|
-
<span style="padding-right: 5px;"><a href="#M000031">advance</a></span>
|
104
|
-
<span style="padding-right: 5px;"><a href="#M000033">ago</a></span>
|
105
|
-
<span style="padding-right: 5px;"><a href="#M000036">beginning_of_day</a></span>
|
106
|
-
<span style="padding-right: 5px;"><a href="#M000032">change</a></span>
|
107
|
-
<span style="padding-right: 5px;"><a href="#M000022">current</a></span>
|
108
|
-
<span style="padding-right: 5px;"><a href="#M000027">days_in_month</a></span>
|
109
|
-
<span style="padding-right: 5px;"><a href="#M000028">days_of_month</a></span>
|
110
|
-
<span style="padding-right: 5px;"><a href="#M000035">in</a></span>
|
111
|
-
<span style="padding-right: 5px;"><a href="#M000037">midnight</a></span>
|
112
|
-
<span style="padding-right: 5px;"><a href="#M000029">month_name</a></span>
|
113
|
-
<span style="padding-right: 5px;"><a href="#M000034">since</a></span>
|
114
|
-
<span style="padding-right: 5px;"><a href="#M000030">stamp</a></span>
|
115
|
-
<span style="padding-right: 5px;"><a href="#M000023">to_date</a></span>
|
116
|
-
<span style="padding-right: 5px;"><a href="#M000024">to_datetime</a></span>
|
117
|
-
<span style="padding-right: 5px;"><a href="#M000025">to_time</a></span>
|
118
|
-
<span style="padding-right: 5px;"><a href="#M000021">tomorrow</a></span>
|
119
|
-
<span style="padding-right: 5px;"><a href="#M000039">tomorrow</a></span>
|
120
|
-
<span style="padding-right: 5px;"><a href="#M000026">xmlschema</a></span>
|
121
|
-
<span style="padding-right: 5px;"><a href="#M000038">yesterday</a></span>
|
122
|
-
<span style="padding-right: 5px;"><a href="#M000020">yesterday</a></span>
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
<div class="sectiontitle">Constants</div>
|
128
|
-
<table border='0' cellpadding='5'>
|
129
|
-
<tr valign='top'>
|
130
|
-
<td class="attr-name">FORMAT</td>
|
131
|
-
<td>=</td>
|
132
|
-
<td class="attr-value">{ :short => "%e %b", :long => "%B %e, %Y", :db => "%Y-%m-%d", :number => "%Y%m%d", :rfc822 => "%e %b %Y", :default => "%Y-%m-%d", nil => "%Y-%m-%d"</td>
|
133
|
-
</tr>
|
134
|
-
</table>
|
135
|
-
|
136
|
-
|
137
|
-
<div class="sectiontitle">Public Class methods</div>
|
138
|
-
<div class="method">
|
139
|
-
<div class="title">
|
140
|
-
<a name="M000022"></a><b>current</b>()
|
141
|
-
</div>
|
142
|
-
<div class="description">
|
143
|
-
<p>
|
144
|
-
Returns Time.zone.today when config.time_zone is set, otherwise just
|
145
|
-
returns Date.today.
|
146
|
-
</p>
|
147
|
-
</div>
|
148
|
-
<div class="sourcecode">
|
149
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000022_source')" id="l_M000022_source">+</a> ]</p>
|
150
|
-
<div id="M000022_source" class="dyn-source">
|
151
|
-
<pre>
|
152
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 43</span>
|
153
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">current</span>
|
154
|
-
<span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">zone_default</span> <span class="ruby-value">? </span><span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">zone</span>.<span class="ruby-identifier">today</span> <span class="ruby-operator">:</span> <span class="ruby-operator">::</span><span class="ruby-constant">Date</span>.<span class="ruby-identifier">today</span>
|
155
|
-
<span class="ruby-keyword kw">end</span>
|
156
|
-
</pre>
|
157
|
-
</div>
|
158
|
-
</div>
|
159
|
-
</div>
|
160
|
-
<div class="method">
|
161
|
-
<div class="title">
|
162
|
-
<a name="M000021"></a><b>tomorrow</b>()
|
163
|
-
</div>
|
164
|
-
<div class="description">
|
165
|
-
<p>
|
166
|
-
Returns a new <a href="Date.html">Date</a> representing the date 1 day
|
167
|
-
after today (i.e. <a href="Date.html#M000021">tomorrow</a>‘s date).
|
168
|
-
</p>
|
169
|
-
</div>
|
170
|
-
<div class="sourcecode">
|
171
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000021_source')" id="l_M000021_source">+</a> ]</p>
|
172
|
-
<div id="M000021_source" class="dyn-source">
|
173
|
-
<pre>
|
174
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 38</span>
|
175
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">tomorrow</span>
|
176
|
-
<span class="ruby-operator">::</span><span class="ruby-constant">Date</span>.<span class="ruby-identifier">today</span>.<span class="ruby-identifier">tomorrow</span>
|
177
|
-
<span class="ruby-keyword kw">end</span>
|
178
|
-
</pre>
|
179
|
-
</div>
|
180
|
-
</div>
|
181
|
-
</div>
|
182
|
-
<div class="method">
|
183
|
-
<div class="title">
|
184
|
-
<a name="M000020"></a><b>yesterday</b>()
|
185
|
-
</div>
|
186
|
-
<div class="description">
|
187
|
-
<p>
|
188
|
-
Returns a new <a href="Date.html">Date</a> representing the date 1 day <a
|
189
|
-
href="Date.html#M000033">ago</a> (i.e. <a
|
190
|
-
href="Date.html#M000020">yesterday</a>‘s date).
|
191
|
-
</p>
|
192
|
-
</div>
|
193
|
-
<div class="sourcecode">
|
194
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000020_source')" id="l_M000020_source">+</a> ]</p>
|
195
|
-
<div id="M000020_source" class="dyn-source">
|
196
|
-
<pre>
|
197
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 33</span>
|
198
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">yesterday</span>
|
199
|
-
<span class="ruby-operator">::</span><span class="ruby-constant">Date</span>.<span class="ruby-identifier">today</span>.<span class="ruby-identifier">yesterday</span>
|
200
|
-
<span class="ruby-keyword kw">end</span>
|
201
|
-
</pre>
|
202
|
-
</div>
|
203
|
-
</div>
|
204
|
-
</div>
|
205
|
-
<div class="sectiontitle">Public Instance methods</div>
|
206
|
-
<div class="method">
|
207
|
-
<div class="title">
|
208
|
-
<a name="M000031"></a><b>advance</b>(options)
|
209
|
-
</div>
|
210
|
-
<div class="description">
|
211
|
-
<p>
|
212
|
-
Provides precise <a href="Date.html">Date</a> calculations for years,
|
213
|
-
months, and days. The <tt>options</tt> parameter takes a hash with any of
|
214
|
-
these keys: <tt>:years</tt>, <tt>:months</tt>, <tt>:weeks</tt>,
|
215
|
-
<tt>:days</tt>.
|
216
|
-
</p>
|
217
|
-
</div>
|
218
|
-
<div class="sourcecode">
|
219
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000031_source')" id="l_M000031_source">+</a> ]</p>
|
220
|
-
<div id="M000031_source" class="dyn-source">
|
221
|
-
<pre>
|
222
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 139</span>
|
223
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">options</span>)
|
224
|
-
<span class="ruby-identifier">d</span> = <span class="ruby-keyword kw">self</span>
|
225
|
-
<span class="ruby-identifier">d</span> = <span class="ruby-identifier">d</span> <span class="ruby-operator">>></span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:years</span>) <span class="ruby-operator">*</span> <span class="ruby-value">12</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:years</span>]
|
226
|
-
<span class="ruby-identifier">d</span> = <span class="ruby-identifier">d</span> <span class="ruby-operator">>></span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:months</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:months</span>]
|
227
|
-
<span class="ruby-identifier">d</span> = <span class="ruby-identifier">d</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:weeks</span>) <span class="ruby-operator">*</span> <span class="ruby-value">7</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:weeks</span>]
|
228
|
-
<span class="ruby-identifier">d</span> = <span class="ruby-identifier">d</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:days</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:days</span>]
|
229
|
-
<span class="ruby-identifier">d</span>
|
230
|
-
<span class="ruby-keyword kw">end</span>
|
231
|
-
</pre>
|
232
|
-
</div>
|
233
|
-
</div>
|
234
|
-
</div>
|
235
|
-
<div class="method">
|
236
|
-
<div class="title">
|
237
|
-
<a name="M000033"></a><b>ago</b>(seconds)
|
238
|
-
</div>
|
239
|
-
<div class="description">
|
240
|
-
<p>
|
241
|
-
Converts <a href="Date.html">Date</a> to a <a href="Time.html">Time</a> (or
|
242
|
-
<a href="DateTime.html">DateTime</a> if necessary) with the time portion
|
243
|
-
set to the beginning of the day (0:00) and then subtracts the specified
|
244
|
-
number of seconds
|
245
|
-
</p>
|
246
|
-
</div>
|
247
|
-
<div class="sourcecode">
|
248
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000033_source')" id="l_M000033_source">+</a> ]</p>
|
249
|
-
<div id="M000033_source" class="dyn-source">
|
250
|
-
<pre>
|
251
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 164</span>
|
252
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ago</span>(<span class="ruby-identifier">seconds</span>)
|
253
|
-
<span class="ruby-identifier">to_time</span>.<span class="ruby-identifier">since</span>(<span class="ruby-operator">-</span><span class="ruby-identifier">seconds</span>)
|
254
|
-
<span class="ruby-keyword kw">end</span>
|
255
|
-
</pre>
|
256
|
-
</div>
|
257
|
-
</div>
|
258
|
-
</div>
|
259
|
-
<div class="method">
|
260
|
-
<div class="title">
|
261
|
-
<a name="M000036"></a><b>beginning_of_day</b>()
|
262
|
-
</div>
|
263
|
-
<div class="description">
|
264
|
-
<p>
|
265
|
-
Converts <a href="Date.html">Date</a> to a <a href="Time.html">Time</a> (or
|
266
|
-
<a href="DateTime.html">DateTime</a> if necessary) with the time portion
|
267
|
-
set to the beginning of the day (0:00)
|
268
|
-
</p>
|
269
|
-
</div>
|
270
|
-
<div class="aka">
|
271
|
-
This method is also aliased as
|
272
|
-
<a href="Date.html#M000037">midnight</a>
|
273
|
-
</div>
|
274
|
-
<div class="sourcecode">
|
275
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000036_source')" id="l_M000036_source">+</a> ]</p>
|
276
|
-
<div id="M000036_source" class="dyn-source">
|
277
|
-
<pre>
|
278
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 176</span>
|
279
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginning_of_day</span>
|
280
|
-
<span class="ruby-identifier">to_time</span>
|
281
|
-
<span class="ruby-keyword kw">end</span>
|
282
|
-
</pre>
|
283
|
-
</div>
|
284
|
-
</div>
|
285
|
-
</div>
|
286
|
-
<div class="method">
|
287
|
-
<div class="title">
|
288
|
-
<a name="M000032"></a><b>change</b>(options)
|
289
|
-
</div>
|
290
|
-
<div class="description">
|
291
|
-
<p>
|
292
|
-
Returns a new <a href="Date.html">Date</a> where one or more of the
|
293
|
-
elements have been changed according to the <tt>options</tt> parameter.
|
294
|
-
</p>
|
295
|
-
<p>
|
296
|
-
Examples:
|
297
|
-
</p>
|
298
|
-
<pre>
|
299
|
-
Date.new(2007, 5, 12).change(:day => 1) # => Date.new(2007, 5, 1)
|
300
|
-
Date.new(2007, 5, 12).change(:year => 2005, :month => 1) # => Date.new(2005, 1, 12)
|
301
|
-
</pre>
|
302
|
-
</div>
|
303
|
-
<div class="sourcecode">
|
304
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000032_source')" id="l_M000032_source">+</a> ]</p>
|
305
|
-
<div id="M000032_source" class="dyn-source">
|
306
|
-
<pre>
|
307
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 154</span>
|
308
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">change</span>(<span class="ruby-identifier">options</span>)
|
309
|
-
<span class="ruby-operator">::</span><span class="ruby-constant">Date</span>.<span class="ruby-identifier">new</span>(
|
310
|
-
<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:year</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">year</span>,
|
311
|
-
<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:month</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">month</span>,
|
312
|
-
<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:day</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">day</span>
|
313
|
-
)
|
314
|
-
<span class="ruby-keyword kw">end</span>
|
315
|
-
</pre>
|
316
|
-
</div>
|
317
|
-
</div>
|
318
|
-
</div>
|
319
|
-
<div class="method">
|
320
|
-
<div class="title">
|
321
|
-
<a name="M000027"></a><b>days_in_month</b>()
|
322
|
-
</div>
|
323
|
-
<div class="description">
|
324
|
-
<p>
|
325
|
-
Returns the number of days <a href="Date.html#M000035">in</a> the
|
326
|
-
date‘s month.
|
327
|
-
</p>
|
328
|
-
<pre>
|
329
|
-
Date.new(2004,2).days_in_month #=> 28
|
330
|
-
</pre>
|
331
|
-
<p>
|
332
|
-
CREDIT: Ken Kunz.
|
333
|
-
</p>
|
334
|
-
</div>
|
335
|
-
<div class="sourcecode">
|
336
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000027_source')" id="l_M000027_source">+</a> ]</p>
|
337
|
-
<div id="M000027_source" class="dyn-source">
|
338
|
-
<pre>
|
339
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 89</span>
|
340
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">days_in_month</span>
|
341
|
-
<span class="ruby-constant">Date</span>.<span class="ruby-identifier">civil</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-value">-1</span>).<span class="ruby-identifier">day</span>
|
342
|
-
<span class="ruby-keyword kw">end</span>
|
343
|
-
</pre>
|
344
|
-
</div>
|
345
|
-
</div>
|
346
|
-
</div>
|
347
|
-
<div class="method">
|
348
|
-
<div class="title">
|
349
|
-
<a name="M000028"></a><b>days_of_month</b>()
|
350
|
-
</div>
|
351
|
-
<div class="sourcecode">
|
352
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000028_source')" id="l_M000028_source">+</a> ]</p>
|
353
|
-
<div id="M000028_source" class="dyn-source">
|
354
|
-
<pre>
|
355
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 93</span>
|
356
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">days_of_month</span>
|
357
|
-
(<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">days_in_month</span>).<span class="ruby-identifier">to_a</span>
|
358
|
-
<span class="ruby-keyword kw">end</span>
|
359
|
-
</pre>
|
360
|
-
</div>
|
361
|
-
</div>
|
362
|
-
</div>
|
363
|
-
<div class="method">
|
364
|
-
<div class="title">
|
365
|
-
<a name="M000035"></a><b>in</b>(seconds)
|
366
|
-
</div>
|
367
|
-
<div class="description">
|
368
|
-
<p>
|
369
|
-
Alias for <a href="Date.html#M000034">since</a>
|
370
|
-
</p>
|
371
|
-
</div>
|
372
|
-
</div>
|
373
|
-
<div class="method">
|
374
|
-
<div class="title">
|
375
|
-
<a name="M000037"></a><b>midnight</b>()
|
376
|
-
</div>
|
377
|
-
<div class="description">
|
378
|
-
<p>
|
379
|
-
Alias for <a href="Date.html#M000036">beginning_of_day</a>
|
380
|
-
</p>
|
381
|
-
</div>
|
382
|
-
</div>
|
383
|
-
<div class="method">
|
384
|
-
<div class="title">
|
385
|
-
<a name="M000029"></a><b>month_name</b>()
|
386
|
-
</div>
|
387
|
-
<div class="description">
|
388
|
-
<p>
|
389
|
-
Get the month name for this date object
|
390
|
-
</p>
|
391
|
-
<p>
|
392
|
-
CREDIT: Benjamin Oakes
|
393
|
-
</p>
|
394
|
-
</div>
|
395
|
-
<div class="sourcecode">
|
396
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000029_source')" id="l_M000029_source">+</a> ]</p>
|
397
|
-
<div id="M000029_source" class="dyn-source">
|
398
|
-
<pre>
|
399
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 101</span>
|
400
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">month_name</span>
|
401
|
-
<span class="ruby-constant">MONTHNAMES</span>[<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">month</span>]
|
402
|
-
<span class="ruby-keyword kw">end</span>
|
403
|
-
</pre>
|
404
|
-
</div>
|
405
|
-
</div>
|
406
|
-
</div>
|
407
|
-
<div class="method">
|
408
|
-
<div class="title">
|
409
|
-
<a name="M000034"></a><b>since</b>(seconds)
|
410
|
-
</div>
|
411
|
-
<div class="description">
|
412
|
-
<p>
|
413
|
-
Converts <a href="Date.html">Date</a> to a <a href="Time.html">Time</a> (or
|
414
|
-
<a href="DateTime.html">DateTime</a> if necessary) with the time portion
|
415
|
-
set to the beginning of the day (0:00) and then adds the specified number
|
416
|
-
of seconds
|
417
|
-
</p>
|
418
|
-
</div>
|
419
|
-
<div class="aka">
|
420
|
-
This method is also aliased as
|
421
|
-
<a href="Date.html#M000035">in</a>
|
422
|
-
</div>
|
423
|
-
<div class="sourcecode">
|
424
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000034_source')" id="l_M000034_source">+</a> ]</p>
|
425
|
-
<div id="M000034_source" class="dyn-source">
|
426
|
-
<pre>
|
427
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 170</span>
|
428
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">since</span>(<span class="ruby-identifier">seconds</span>)
|
429
|
-
<span class="ruby-identifier">to_time</span>.<span class="ruby-identifier">since</span>(<span class="ruby-identifier">seconds</span>)
|
430
|
-
<span class="ruby-keyword kw">end</span>
|
431
|
-
</pre>
|
432
|
-
</div>
|
433
|
-
</div>
|
434
|
-
</div>
|
435
|
-
<div class="method">
|
436
|
-
<div class="title">
|
437
|
-
<a name="M000030"></a><b>stamp</b>(format=:default)
|
438
|
-
</div>
|
439
|
-
<div class="description">
|
440
|
-
<p>
|
441
|
-
Convert to a formatted string. See DATE_FORMATS for predefined formats.
|
442
|
-
</p>
|
443
|
-
<p>
|
444
|
-
This method is aliased to <tt>to_s</tt>.
|
445
|
-
</p>
|
446
|
-
<h4>Examples:</h4>
|
447
|
-
<pre>
|
448
|
-
date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
|
449
|
-
|
450
|
-
date.stamp(:db) # => "2007-11-10"
|
451
|
-
date.stamp(:short) # => "10 Nov"
|
452
|
-
date.stamp(:long) # => "November 10, 2007"
|
453
|
-
date.stamp(:rfc822) # => "10 Nov 2007"
|
454
|
-
</pre>
|
455
|
-
<h2>Adding your own formats to <a href="Date.html#M000030">stamp</a></h2>
|
456
|
-
<p>
|
457
|
-
You can add your own formats to the Date::FORMAT hash. Use the format name
|
458
|
-
as the hash key and a strftime string as the value. Eg.
|
459
|
-
</p>
|
460
|
-
<pre>
|
461
|
-
Date::FORMAT[:month_and_year] = "%B %Y"
|
462
|
-
</pre>
|
463
|
-
</div>
|
464
|
-
<div class="sourcecode">
|
465
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000030_source')" id="l_M000030_source">+</a> ]</p>
|
466
|
-
<div id="M000030_source" class="dyn-source">
|
467
|
-
<pre>
|
468
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 124</span>
|
469
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stamp</span>(<span class="ruby-identifier">format</span>=<span class="ruby-identifier">:default</span>)
|
470
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">formatter</span> = <span class="ruby-constant">FORMAT</span>[<span class="ruby-identifier">format</span>]
|
471
|
-
<span class="ruby-identifier">strftime</span>(<span class="ruby-identifier">formatter</span>)
|
472
|
-
<span class="ruby-keyword kw">else</span>
|
473
|
-
<span class="ruby-identifier">to_s</span>
|
474
|
-
<span class="ruby-keyword kw">end</span>
|
475
|
-
<span class="ruby-keyword kw">end</span>
|
476
|
-
</pre>
|
477
|
-
</div>
|
478
|
-
</div>
|
479
|
-
</div>
|
480
|
-
<div class="method">
|
481
|
-
<div class="title">
|
482
|
-
<a name="M000023"></a><b>to_date</b>()
|
483
|
-
</div>
|
484
|
-
<div class="description">
|
485
|
-
<p>
|
486
|
-
A method to keep <a href="Time.html">Time</a>, <a href="Date.html">Date</a>
|
487
|
-
and <a href="DateTime.html">DateTime</a> instances interchangeable on
|
488
|
-
conversions. In this case, it simply returns <tt>self</tt>.
|
489
|
-
</p>
|
490
|
-
</div>
|
491
|
-
<div class="sourcecode">
|
492
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000023_source')" id="l_M000023_source">+</a> ]</p>
|
493
|
-
<div id="M000023_source" class="dyn-source">
|
494
|
-
<pre>
|
495
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 49</span>
|
496
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_date</span>
|
497
|
-
<span class="ruby-keyword kw">self</span>
|
498
|
-
<span class="ruby-keyword kw">end</span>
|
499
|
-
</pre>
|
500
|
-
</div>
|
501
|
-
</div>
|
502
|
-
</div>
|
503
|
-
<div class="method">
|
504
|
-
<div class="title">
|
505
|
-
<a name="M000024"></a><b>to_datetime</b>()
|
506
|
-
</div>
|
507
|
-
<div class="description">
|
508
|
-
<p>
|
509
|
-
Converts a <a href="Date.html">Date</a> instance to a <a
|
510
|
-
href="DateTime.html">DateTime</a>, where the time is set to the beginning
|
511
|
-
of the day and UTC offset is set to 0.
|
512
|
-
</p>
|
513
|
-
<h4>Example:</h4>
|
514
|
-
<pre>
|
515
|
-
date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
|
516
|
-
|
517
|
-
date.to_datetime # => Sat, 10 Nov 2007 00:00:00 0000
|
518
|
-
</pre>
|
519
|
-
</div>
|
520
|
-
<div class="sourcecode">
|
521
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000024_source')" id="l_M000024_source">+</a> ]</p>
|
522
|
-
<div id="M000024_source" class="dyn-source">
|
523
|
-
<pre>
|
524
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 60</span>
|
525
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_datetime</span>
|
526
|
-
<span class="ruby-operator">::</span><span class="ruby-constant">DateTime</span>.<span class="ruby-identifier">civil</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-value">0</span>, <span class="ruby-value">0</span>, <span class="ruby-value">0</span>, <span class="ruby-value">0</span>)
|
527
|
-
<span class="ruby-keyword kw">end</span>
|
528
|
-
</pre>
|
529
|
-
</div>
|
530
|
-
</div>
|
531
|
-
</div>
|
532
|
-
<div class="method">
|
533
|
-
<div class="title">
|
534
|
-
<a name="M000025"></a><b>to_time</b>(form=:local)
|
535
|
-
</div>
|
536
|
-
<div class="description">
|
537
|
-
<p>
|
538
|
-
Converts a <a href="Date.html">Date</a> instance to a <a
|
539
|
-
href="Time.html">Time</a>, where the time is set to the beginning of the
|
540
|
-
day. The timezone can be either :local or :utc (default :local).
|
541
|
-
</p>
|
542
|
-
<pre>
|
543
|
-
date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
|
544
|
-
|
545
|
-
date.to_time # => Sat Nov 10 00:00:00 0800 2007
|
546
|
-
date.to_time(:local) # => Sat Nov 10 00:00:00 0800 2007
|
547
|
-
|
548
|
-
date.to_time(:utc) # => Sat Nov 10 00:00:00 UTC 2007
|
549
|
-
</pre>
|
550
|
-
</div>
|
551
|
-
<div class="sourcecode">
|
552
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000025_source')" id="l_M000025_source">+</a> ]</p>
|
553
|
-
<div id="M000025_source" class="dyn-source">
|
554
|
-
<pre>
|
555
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 74</span>
|
556
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_time</span>(<span class="ruby-identifier">form</span>=<span class="ruby-identifier">:local</span>)
|
557
|
-
<span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">form</span>, <span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>)
|
558
|
-
<span class="ruby-comment cmt">#::Time.send("#{form}_time", year, month, day)</span>
|
559
|
-
<span class="ruby-keyword kw">end</span>
|
560
|
-
</pre>
|
561
|
-
</div>
|
562
|
-
</div>
|
563
|
-
</div>
|
564
|
-
<div class="method">
|
565
|
-
<div class="title">
|
566
|
-
<a name="M000039"></a><b>tomorrow</b>()
|
567
|
-
</div>
|
568
|
-
<div class="description">
|
569
|
-
<p>
|
570
|
-
Convenience method which returns a new <a href="Date.html">Date</a>/<a
|
571
|
-
href="DateTime.html">DateTime</a> representing the time 1 day <a
|
572
|
-
href="Date.html#M000034">since</a> the instance time
|
573
|
-
</p>
|
574
|
-
</div>
|
575
|
-
<div class="sourcecode">
|
576
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000039_source')" id="l_M000039_source">+</a> ]</p>
|
577
|
-
<div id="M000039_source" class="dyn-source">
|
578
|
-
<pre>
|
579
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 187</span>
|
580
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tomorrow</span>
|
581
|
-
<span class="ruby-keyword kw">self</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
|
582
|
-
<span class="ruby-keyword kw">end</span>
|
583
|
-
</pre>
|
584
|
-
</div>
|
585
|
-
</div>
|
586
|
-
</div>
|
587
|
-
<div class="method">
|
588
|
-
<div class="title">
|
589
|
-
<a name="M000026"></a><b>xmlschema</b>()
|
590
|
-
</div>
|
591
|
-
<div class="sourcecode">
|
592
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000026_source')" id="l_M000026_source">+</a> ]</p>
|
593
|
-
<div id="M000026_source" class="dyn-source">
|
594
|
-
<pre>
|
595
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 79</span>
|
596
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">xmlschema</span>
|
597
|
-
<span class="ruby-identifier">to_time</span>.<span class="ruby-identifier">xmlschema</span>
|
598
|
-
<span class="ruby-keyword kw">end</span>
|
599
|
-
</pre>
|
600
|
-
</div>
|
601
|
-
</div>
|
602
|
-
</div>
|
603
|
-
<div class="method">
|
604
|
-
<div class="title">
|
605
|
-
<a name="M000038"></a><b>yesterday</b>()
|
606
|
-
</div>
|
607
|
-
<div class="description">
|
608
|
-
<p>
|
609
|
-
Convenience method which returns a new <a href="Date.html">Date</a>/<a
|
610
|
-
href="DateTime.html">DateTime</a> representing the time 1 day <a
|
611
|
-
href="Date.html#M000033">ago</a>
|
612
|
-
</p>
|
613
|
-
</div>
|
614
|
-
<div class="sourcecode">
|
615
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000038_source')" id="l_M000038_source">+</a> ]</p>
|
616
|
-
<div id="M000038_source" class="dyn-source">
|
617
|
-
<pre>
|
618
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/date.rb, line 182</span>
|
619
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">yesterday</span>
|
620
|
-
<span class="ruby-keyword kw">self</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
|
621
|
-
<span class="ruby-keyword kw">end</span>
|
622
|
-
</pre>
|
623
|
-
</div>
|
624
|
-
</div>
|
625
|
-
</div>
|
626
|
-
</div>
|
627
|
-
|
628
|
-
</div>
|
629
|
-
|
630
|
-
</body>
|
631
|
-
</html>
|