richunits 0.5.0 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/MANIFEST +12 -24
- data/README +34 -24
- data/TODO +19 -2
- data/lib/richunits/duration.rb +29 -18
- data/meta/anthology +1 -0
- data/meta/name +1 -0
- data/meta/repository +1 -0
- data/meta/title +1 -1
- data/meta/version +1 -1
- data/test/test_times.rb +15 -0
- metadata +29 -38
- data/VERSION +0 -1
- data/doc/ads/rdoc.html +0 -12
- data/doc/images/ruby-md.png +0 -0
- data/doc/images/ruby-sm.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tiger-sm.png +0 -0
- data/doc/images/tiger_logo.png +0 -0
- data/doc/index.css +0 -179
- data/doc/index.html +0 -163
data/MANIFEST
CHANGED
@@ -1,40 +1,28 @@
|
|
1
|
-
doc
|
2
|
-
lib
|
3
|
-
meta
|
4
|
-
test
|
5
1
|
CHANGES
|
2
|
+
COPYING
|
3
|
+
MANIFEST
|
4
|
+
README
|
6
5
|
RELEASE
|
7
6
|
TODO
|
8
|
-
README
|
9
|
-
VERSION
|
10
|
-
COPYING
|
11
|
-
doc/ads
|
12
|
-
doc/index.css
|
13
|
-
doc/index.html
|
14
|
-
doc/images
|
15
|
-
doc/ads/rdoc.html
|
16
|
-
doc/images/ruby.png
|
17
|
-
doc/images/ruby-md.png
|
18
|
-
doc/images/tiger_logo.png
|
19
|
-
doc/images/ruby-sm.png
|
20
|
-
doc/images/tiger-sm.png
|
21
7
|
lib/rich_units.rb
|
22
8
|
lib/richunits
|
23
9
|
lib/richunits.rb
|
24
|
-
lib/richunits/
|
10
|
+
lib/richunits/bytes.rb
|
25
11
|
lib/richunits/duration.rb
|
26
12
|
lib/richunits/multipliers.rb
|
13
|
+
lib/richunits/times.rb
|
27
14
|
lib/richunits/weekdays.rb
|
28
|
-
|
15
|
+
meta/abstract
|
16
|
+
meta/anthology
|
17
|
+
meta/contact
|
29
18
|
meta/created
|
30
|
-
meta/repository
|
31
19
|
meta/homepage
|
32
|
-
meta/
|
20
|
+
meta/license
|
21
|
+
meta/name
|
22
|
+
meta/repository
|
33
23
|
meta/title
|
34
24
|
meta/version
|
35
|
-
meta/license
|
36
|
-
meta/contact
|
37
|
-
test/test_duration.rb
|
38
25
|
test/test_bytes.rb
|
26
|
+
test/test_duration.rb
|
39
27
|
test/test_multipliers.rb
|
40
28
|
test/test_times.rb
|
data/README
CHANGED
@@ -1,52 +1,62 @@
|
|
1
|
-
=
|
1
|
+
= RichUnits
|
2
2
|
|
3
3
|
Easy Units for Ruby
|
4
4
|
|
5
|
-
|
5
|
+
* http://rubyworks.github.com/richunits/
|
6
|
+
* http://richunits.rubyforge.org/ (old site)
|
6
7
|
|
7
|
-
== Usage
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
== DESCRIPTION:
|
10
|
+
|
11
|
+
RichUnits is simple units system based on Rich Kilmer's original
|
12
|
+
time.rb script, in which different measures of time are represented
|
13
|
+
as seconds via extensions to the Numeric class. Later, Ruby on Rails'
|
14
|
+
ActiveSupport library adopted this script and expanded upon it.
|
15
|
+
RichUnits borrows from their work and a few other renditions this code
|
16
|
+
that have made the rounds to create a robust stand-alone version.
|
17
|
+
|
18
|
+
Unique to RichUnits' rendition is the Duration class (inspired by Matthew
|
19
|
+
Harris' version by the same name). Originally time measures were stored as
|
20
|
+
integers representing seconds. The Duration class instead stores the seconds
|
21
|
+
as an attribute and adds an optional segements property which can be used to
|
22
|
+
select exactly how to segment up the time period (years, week, days, etc.).
|
23
|
+
|
24
|
+
|
25
|
+
== SYNOPSIS:
|
26
|
+
|
27
|
+
You only need to require 'richunits' and all of RichUnit's functionality
|
28
|
+
becomes available.
|
11
29
|
|
12
30
|
require 'richunits'
|
13
31
|
|
14
32
|
2.hours #=> 7200
|
15
33
|
|
16
|
-
RichUnits also includes a Duration class (inspired by Matthew Harris' version)
|
17
|
-
for storing time measures. These measure were originally stored as Integer
|
18
|
-
seconds. The Duration class instead stores the seconds as an attribute and
|
19
|
-
adds a an optional segements property which can be used to select exactly
|
20
|
-
how to segment up the time period (years, week, days, etc.).
|
21
|
-
|
22
34
|
See RDocs for complete API documentation.
|
23
35
|
|
24
|
-
== Development
|
25
|
-
|
26
|
-
GitHub Repository.
|
27
36
|
|
28
|
-
|
37
|
+
== DEVELOPMENT:
|
29
38
|
|
30
|
-
|
39
|
+
RichUnits utilizes GitHub for development. You will find the git
|
40
|
+
repo under the rubyworks account.
|
31
41
|
|
32
|
-
|
42
|
+
git://github.com/rubyworks/richunits.git
|
33
43
|
|
34
|
-
|
44
|
+
RichUnits utilizes the Syckle build system.
|
35
45
|
|
36
|
-
* Should we rename the Rubyforge project from richunits to rich_units?
|
37
46
|
|
38
|
-
==
|
47
|
+
== COPYRIGHTS:
|
39
48
|
|
40
|
-
Copyright (c) 2008
|
49
|
+
Copyright (c) 2008 Thomas Sawyer
|
41
50
|
Copyright (c) 2006 Matthew Harris
|
42
51
|
Copyright (c) 2004 Rich Kilmer
|
43
52
|
|
44
53
|
If you have contributed to this code and feel you deserve mention
|
45
|
-
in the copyright notice, please let
|
54
|
+
in the copyright notice, please let me know. Since this code has
|
46
55
|
been through a number of hands and other projects (Facets and
|
47
56
|
ActiveSupport among them) it is hard to identify exactly who is
|
48
|
-
responsible for what. Nonetheless, Rich Kilmer is the
|
49
|
-
|
57
|
+
responsible for what. Nonetheless, Rich Kilmer is the initiator
|
58
|
+
of the whole idea (AFAIK), so I figure much of the rights belong
|
59
|
+
to him.
|
50
60
|
|
51
61
|
RichUnits is distributed under the terms of the MIT license.
|
52
62
|
|
data/TODO
CHANGED
@@ -1,5 +1,22 @@
|
|
1
|
+
= TODO List
|
1
2
|
|
2
|
-
|
3
|
+
== Achieve 99.9% drop-in compatability with ActiveSupport.
|
3
4
|
|
4
|
-
*
|
5
|
+
* Duration may be the big difficulty here.
|
6
|
+
|
7
|
+
|
8
|
+
== Better TimeZone support
|
9
|
+
|
10
|
+
* tgzinfo?
|
11
|
+
|
12
|
+
|
13
|
+
== Documentation
|
14
|
+
|
15
|
+
I was looking through the rdoc at
|
16
|
+
|
17
|
+
http://tigerops.rubyforge.org/rich_units/rdoc/index.html
|
18
|
+
|
19
|
+
and found that the names generated by rdoc for the bit and byte human readable string methods is out of synch with the examples in the documentation for each of the methods. The actual method names Numeric#strfbits and Numeric#strfbytes work but the method names Numeric#bits_to_s and Numeric#bytes_to_s that are shown in the examples for each method do not work.
|
20
|
+
|
21
|
+
(from Larry Baltz)
|
5
22
|
|
data/lib/richunits/duration.rb
CHANGED
@@ -12,40 +12,51 @@ module RichUnits
|
|
12
12
|
|
13
13
|
SEGMENTS = %w{years weeks days hours minutes seconds}.collect{ |s| s.to_sym }
|
14
14
|
|
15
|
+
# Same as #new
|
15
16
|
#
|
16
|
-
def self.[](seconds,
|
17
|
-
new(seconds,
|
17
|
+
def self.[](seconds, segmentA=nil, segmentB=nil)
|
18
|
+
new(seconds, segmentA, segmentB)
|
18
19
|
end
|
19
20
|
|
21
|
+
# New duration.
|
20
22
|
#
|
21
|
-
|
23
|
+
# call-seq:
|
24
|
+
# new(seconds)
|
25
|
+
# new(seconds, max-period)
|
26
|
+
# new(seconds, max-period, min-period)
|
27
|
+
# new(seconds, [period1, period2, ...])
|
28
|
+
#
|
29
|
+
def initialize(seconds=0, segmentA=nil, segmentB=nil)
|
22
30
|
@seconds = seconds.to_i
|
23
|
-
reset_segments(
|
31
|
+
reset_segments(segmentA, segmentB)
|
24
32
|
end
|
25
33
|
|
26
|
-
#
|
34
|
+
# List of period segments.
|
27
35
|
def segments; @segments; end
|
28
36
|
|
37
|
+
# Reset segments.
|
38
|
+
#
|
39
|
+
# call-seq:
|
40
|
+
# reset_segments(max-period)
|
41
|
+
# reset_segments(max-period, min-period)
|
42
|
+
# reset_segments([period1, period2, ...])
|
29
43
|
#
|
30
|
-
def reset_segments(
|
31
|
-
|
32
|
-
when 0
|
44
|
+
def reset_segments(segmentA=nil, segmentB=nil)
|
45
|
+
if !segmentA
|
33
46
|
@segments = [:days, :hours, :minutes, :seconds]
|
34
|
-
|
35
|
-
case
|
47
|
+
elsif !segmentB
|
48
|
+
case segmentA
|
36
49
|
when Array
|
37
|
-
@segments =
|
50
|
+
@segments = segmentA.map{ |p| (p.to_s.downcase.chomp('s') + 's').to_sym }
|
38
51
|
raise ArgumentError unless @segments.all?{ |s| SEGMENTS.include?(s) }
|
39
52
|
else
|
40
|
-
f = SEGMENTS.index(
|
53
|
+
f = SEGMENTS.index(segmentA)
|
41
54
|
@segments = SEGMENTS[f..0]
|
42
55
|
end
|
43
|
-
|
44
|
-
f = SEGMENTS.index(
|
45
|
-
t = SEGMENTS.index(
|
56
|
+
else # segmentA && segmentB
|
57
|
+
f = SEGMENTS.index(segmentA)
|
58
|
+
t = SEGMENTS.index(segmentB)
|
46
59
|
@segments = SEGMENTS[f..t]
|
47
|
-
else
|
48
|
-
raise ArgumentError
|
49
60
|
end
|
50
61
|
end
|
51
62
|
|
@@ -130,7 +141,7 @@ module RichUnits
|
|
130
141
|
self.class.new(@seconds - other.to_i, segments)
|
131
142
|
end
|
132
143
|
|
133
|
-
def
|
144
|
+
def *(other)
|
134
145
|
self.class.new(@seconds * other.to_i, segments)
|
135
146
|
end
|
136
147
|
|
data/meta/anthology
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rubyworks
|
data/meta/name
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
richunits
|
data/meta/repository
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
git://github.com/rubyworks/richunits.git
|
data/meta/title
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
RichUnits
|
data/meta/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6
|
data/test/test_times.rb
CHANGED
@@ -54,6 +54,21 @@ class TC_Times < Test::Unit::TestCase
|
|
54
54
|
assert_equal( t + 1.day, 1.day.after(t) )
|
55
55
|
end
|
56
56
|
|
57
|
+
#
|
58
|
+
|
59
|
+
def test_addition
|
60
|
+
assert_equal(11.minutes, 10.minutes + 1.minute)
|
61
|
+
assert_equal(11.minutes.to_i, (10.minutes + 1.minute).to_i)
|
62
|
+
|
63
|
+
assert_equal(11.minutes, 10.minutes + 60.seconds)
|
64
|
+
assert_equal(11.minutes.to_i, (10.minutes + 60.seconds).to_i)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_multiplication
|
68
|
+
assert_equal(20.minutes, 10.minutes * 2)
|
69
|
+
assert_equal(20.minutes.to_i, (10.minutes * 2).to_i)
|
70
|
+
end
|
71
|
+
|
57
72
|
end
|
58
73
|
|
59
74
|
class WeekdaysTest < Test::Unit::TestCase
|
metadata
CHANGED
@@ -1,20 +1,25 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: richunits
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: "0.6"
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
7
|
-
|
6
|
+
authors: []
|
7
|
+
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-31 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
17
|
-
|
16
|
+
description: |-
|
17
|
+
Rich Kilmer's Unit system provides english-esque methods
|
18
|
+
for working with common units, such as days and bytes and
|
19
|
+
multiplers like kilo, or mega. It does so by reducing basic
|
20
|
+
measures to a lower common denominator, such as seconds for
|
21
|
+
time measures and bits for byte measures.
|
22
|
+
email: 7ransUnit <transfire@gmail.com>
|
18
23
|
executables: []
|
19
24
|
|
20
25
|
extensions: []
|
@@ -25,57 +30,43 @@ extra_rdoc_files:
|
|
25
30
|
- CHANGES
|
26
31
|
- RELEASE
|
27
32
|
- TODO
|
28
|
-
- VERSION
|
29
33
|
- COPYING
|
30
34
|
files:
|
31
|
-
- doc
|
32
|
-
- lib
|
33
|
-
- meta
|
34
|
-
- test
|
35
35
|
- CHANGES
|
36
|
+
- COPYING
|
37
|
+
- MANIFEST
|
38
|
+
- README
|
36
39
|
- RELEASE
|
37
40
|
- TODO
|
38
|
-
- README
|
39
|
-
- VERSION
|
40
|
-
- COPYING
|
41
|
-
- doc/ads
|
42
|
-
- doc/index.css
|
43
|
-
- doc/index.html
|
44
|
-
- doc/images
|
45
|
-
- doc/ads/rdoc.html
|
46
|
-
- doc/images/ruby.png
|
47
|
-
- doc/images/ruby-md.png
|
48
|
-
- doc/images/tiger_logo.png
|
49
|
-
- doc/images/ruby-sm.png
|
50
|
-
- doc/images/tiger-sm.png
|
51
41
|
- lib/rich_units.rb
|
52
|
-
- lib/richunits
|
53
42
|
- lib/richunits.rb
|
54
|
-
- lib/richunits/
|
43
|
+
- lib/richunits/bytes.rb
|
55
44
|
- lib/richunits/duration.rb
|
56
45
|
- lib/richunits/multipliers.rb
|
46
|
+
- lib/richunits/times.rb
|
57
47
|
- lib/richunits/weekdays.rb
|
58
|
-
-
|
48
|
+
- meta/abstract
|
49
|
+
- meta/anthology
|
50
|
+
- meta/contact
|
59
51
|
- meta/created
|
60
|
-
- meta/repository
|
61
52
|
- meta/homepage
|
62
|
-
- meta/
|
53
|
+
- meta/license
|
54
|
+
- meta/name
|
55
|
+
- meta/repository
|
63
56
|
- meta/title
|
64
57
|
- meta/version
|
65
|
-
- meta/license
|
66
|
-
- meta/contact
|
67
|
-
- test/test_duration.rb
|
68
58
|
- test/test_bytes.rb
|
59
|
+
- test/test_duration.rb
|
69
60
|
- test/test_multipliers.rb
|
70
61
|
- test/test_times.rb
|
71
|
-
- MANIFEST
|
72
62
|
has_rdoc: true
|
73
63
|
homepage: http://tigerops.rubyforge.org/richunits
|
64
|
+
licenses: []
|
65
|
+
|
74
66
|
post_install_message:
|
75
67
|
rdoc_options:
|
76
|
-
- --inline-source
|
77
68
|
- --title
|
78
|
-
-
|
69
|
+
- RichUnits API
|
79
70
|
- --main
|
80
71
|
- README
|
81
72
|
require_paths:
|
@@ -95,12 +86,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
86
|
requirements: []
|
96
87
|
|
97
88
|
rubyforge_project: tigerops
|
98
|
-
rubygems_version: 1.
|
89
|
+
rubygems_version: 1.3.5
|
99
90
|
signing_key:
|
100
|
-
specification_version:
|
91
|
+
specification_version: 3
|
101
92
|
summary: Rich Kilmer's Unit system provides english-esque methods
|
102
93
|
test_files:
|
103
|
-
- test/test_duration.rb
|
104
94
|
- test/test_bytes.rb
|
95
|
+
- test/test_duration.rb
|
105
96
|
- test/test_multipliers.rb
|
106
97
|
- test/test_times.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
richunits 0.5.0 beta (2009-05-30)
|
data/doc/ads/rdoc.html
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
<div style="position: absolute; top: 5px; right: 10px;">
|
2
|
-
<script type="text/javascript"><!--
|
3
|
-
google_ad_client = "pub-1126154564663472";
|
4
|
-
//BLOW 234x60
|
5
|
-
google_ad_slot = "6480217558";
|
6
|
-
google_ad_width = 234;
|
7
|
-
google_ad_height = 60;
|
8
|
-
//--></script>
|
9
|
-
<script type="text/javascript"
|
10
|
-
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
|
11
|
-
</script>
|
12
|
-
</div>
|
data/doc/images/ruby-md.png
DELETED
Binary file
|
data/doc/images/ruby-sm.png
DELETED
Binary file
|
data/doc/images/ruby.png
DELETED
Binary file
|
data/doc/images/tiger-sm.png
DELETED
Binary file
|
data/doc/images/tiger_logo.png
DELETED
Binary file
|
data/doc/index.css
DELETED
@@ -1,179 +0,0 @@
|
|
1
|
-
* {
|
2
|
-
padding : 0;
|
3
|
-
margin : 0;
|
4
|
-
font-family : sans-serif;
|
5
|
-
}
|
6
|
-
|
7
|
-
body {
|
8
|
-
color : black;
|
9
|
-
background : white;
|
10
|
-
text-align : center;
|
11
|
-
position : relative;
|
12
|
-
font-size : 10px;
|
13
|
-
}
|
14
|
-
|
15
|
-
p {
|
16
|
-
text-align : justify;
|
17
|
-
font-size : 12px;
|
18
|
-
color : #555;
|
19
|
-
font-weight : normal;
|
20
|
-
margin : 10px 0px 10px 0px;
|
21
|
-
line-height : 1.5em;
|
22
|
-
letter-spacing: 1px;
|
23
|
-
}
|
24
|
-
|
25
|
-
/*
|
26
|
-
p.intro {
|
27
|
-
font-size: 14px;
|
28
|
-
font-weight: normal;
|
29
|
-
letter-spacing: 1px;
|
30
|
-
}
|
31
|
-
*/
|
32
|
-
|
33
|
-
a {
|
34
|
-
color: #EF0040;
|
35
|
-
}
|
36
|
-
|
37
|
-
img {
|
38
|
-
border: none;
|
39
|
-
}
|
40
|
-
|
41
|
-
pre {
|
42
|
-
font-family : monospace;
|
43
|
-
font-size : 8pt;
|
44
|
-
color : #eeeeee;
|
45
|
-
background : #1f0f0f;
|
46
|
-
margin : 10px;
|
47
|
-
font-weight : bold;
|
48
|
-
line-height : 1.5em;
|
49
|
-
padding-top : 15px;
|
50
|
-
text-align : left;
|
51
|
-
}
|
52
|
-
|
53
|
-
h1 {
|
54
|
-
font-size: 60px;
|
55
|
-
}
|
56
|
-
|
57
|
-
h2 {
|
58
|
-
font-size: 40px;
|
59
|
-
text-align: left;
|
60
|
-
margin-top: 50px;
|
61
|
-
}
|
62
|
-
|
63
|
-
h3 {
|
64
|
-
text-align: left;
|
65
|
-
margin-top: 20px;
|
66
|
-
}
|
67
|
-
|
68
|
-
td {
|
69
|
-
vertical-align: top;
|
70
|
-
}
|
71
|
-
|
72
|
-
.container {
|
73
|
-
width : 730px;
|
74
|
-
margin : 0 auto;
|
75
|
-
position : relative;
|
76
|
-
}
|
77
|
-
|
78
|
-
|
79
|
-
.aside {
|
80
|
-
float: left;
|
81
|
-
width: 164px;
|
82
|
-
padding: 20px;
|
83
|
-
margin: 40px;
|
84
|
-
text-align: center;
|
85
|
-
background: black;
|
86
|
-
border: 0px solid gray;
|
87
|
-
margin-top: 40px;
|
88
|
-
}
|
89
|
-
|
90
|
-
.aside a {
|
91
|
-
color: #EF0040;
|
92
|
-
font-weight: bold;
|
93
|
-
}
|
94
|
-
|
95
|
-
.aside p {
|
96
|
-
text-align: center;
|
97
|
-
}
|
98
|
-
|
99
|
-
.header {
|
100
|
-
padding: 70px 40px 50px 60px;
|
101
|
-
background: url(images/ruby-md.png) 500px 30px no-repeat #111111;
|
102
|
-
text-align: left;
|
103
|
-
font-weight: bold;
|
104
|
-
margin-bottom: 20px;
|
105
|
-
border: 1px solid gray;
|
106
|
-
}
|
107
|
-
|
108
|
-
.title {
|
109
|
-
color: white; font-size: 62px;
|
110
|
-
}
|
111
|
-
|
112
|
-
.subtitle {
|
113
|
-
color: white;
|
114
|
-
font-size: 16px;
|
115
|
-
}
|
116
|
-
|
117
|
-
.content {
|
118
|
-
padding: 0 0;
|
119
|
-
}
|
120
|
-
|
121
|
-
.about {
|
122
|
-
margin: 0 0 20px 0;
|
123
|
-
padding: 20px;
|
124
|
-
text-align: justify;
|
125
|
-
font-size: 20pt;
|
126
|
-
font-weight: bold;
|
127
|
-
background: #BF0020;
|
128
|
-
color: white;
|
129
|
-
border: 1px solid pink;
|
130
|
-
}
|
131
|
-
|
132
|
-
.menu {
|
133
|
-
width : 730px;
|
134
|
-
margin : 0 auto;
|
135
|
-
padding : 15px 30px;
|
136
|
-
color : orange;
|
137
|
-
font-size : 12px;
|
138
|
-
text-align : left;
|
139
|
-
}
|
140
|
-
|
141
|
-
.menu a {
|
142
|
-
font-size: 1em;
|
143
|
-
font-weight: bold;
|
144
|
-
color: red;
|
145
|
-
text-decoration: none;
|
146
|
-
}
|
147
|
-
|
148
|
-
.menu a:hover {
|
149
|
-
text-decoration: underline;
|
150
|
-
}
|
151
|
-
|
152
|
-
.ad {
|
153
|
-
border : 0px solid white;
|
154
|
-
text-align : center;
|
155
|
-
}
|
156
|
-
|
157
|
-
.invert {
|
158
|
-
text-align : left;
|
159
|
-
color : white;
|
160
|
-
margin : 0;
|
161
|
-
padding : 15px 15px 15px 15px;
|
162
|
-
background : black;
|
163
|
-
}
|
164
|
-
|
165
|
-
.invert p {
|
166
|
-
text-align : left;
|
167
|
-
color : white;
|
168
|
-
}
|
169
|
-
|
170
|
-
.copyright {
|
171
|
-
padding : 5px;
|
172
|
-
text-align : center;
|
173
|
-
color : gray;
|
174
|
-
font-size : 1.2em;
|
175
|
-
border : 1px solid gray;
|
176
|
-
background : #111111;
|
177
|
-
margin : 20px 1px;
|
178
|
-
}
|
179
|
-
|
data/doc/index.html
DELETED
@@ -1,163 +0,0 @@
|
|
1
|
-
|
2
|
-
<html>
|
3
|
-
|
4
|
-
<head>
|
5
|
-
<title>Rich Units</title>
|
6
|
-
|
7
|
-
<link href="index.css" rel="stylesheet" type="text/css"/>
|
8
|
-
<link href="images/ruby-sm.png" rel="icon"/>
|
9
|
-
|
10
|
-
<META NAME="DESCRIPTION" CONTENT="Rich Units system for the Ruby programming lanaguage.">
|
11
|
-
<META NAME="KEYWORDS" CONTENT="units, ruby, numeric, time">
|
12
|
-
</head>
|
13
|
-
|
14
|
-
<body>
|
15
|
-
|
16
|
-
<div class="menu">
|
17
|
-
<div style="float: right; font-weight: bold;">A <a href="http://tigerops.org">TigerOps</a> PROJECT</div>
|
18
|
-
<!-- <<a href="http://tigerops.rubyforge.org/">Homepage</a>> -->
|
19
|
-
<a href="rdoc/index.html">Documentation</a> ·
|
20
|
-
<a href="http://rubyforge.org/frs/?group_id=7034">Download</a> ·
|
21
|
-
<a href="http://rubyforge.org/projects/richunits">Development</a>
|
22
|
-
</div>
|
23
|
-
|
24
|
-
<div class="container">
|
25
|
-
|
26
|
-
<div class="header">
|
27
|
-
<span class="title">Rich Units</span>
|
28
|
-
</div>
|
29
|
-
|
30
|
-
<div class="content">
|
31
|
-
|
32
|
-
<p class="about">
|
33
|
-
RichUnits is a very easy to use unit system for the Ruby programming language.
|
34
|
-
It is essentially the same system popularized by Ruby on Rails.
|
35
|
-
</p>
|
36
|
-
|
37
|
-
<h2>Introduction</h2>
|
38
|
-
|
39
|
-
<p class="intro">Rich Units is a straight-forward units system based-on the original time
|
40
|
-
units work by Rich Kilmer (circa 2002-2004). Rich Units extends core Ruby with conveneice
|
41
|
-
methods for dealing with measures. The methods work by converting those measures to a low
|
42
|
-
common denominator; for instance all durations are stored in seconds.
|
43
|
-
</p>
|
44
|
-
|
45
|
-
<p class="intro">Rich Units provides essentially the same unit system used by
|
46
|
-
<a href="http://www.rubyonrails.org/">Ruby on Rails</a>*. But Rich Units seeks to imporve
|
47
|
-
upon this code, and provides a superset of functionality, partly derived from the
|
48
|
-
<a href="facets.rubyforge.org">Ruby Facets</a> distribution of the same libraries.
|
49
|
-
Ultimately Rich Units intent is to provide a better system than either of these large
|
50
|
-
projects can provide, by virture of a dedicated development track.
|
51
|
-
</p>
|
52
|
-
|
53
|
-
<p><span style="font-size:0.8em;"> *with the present exception of the timezone extensions (coming soon).</span></p>
|
54
|
-
|
55
|
-
<h2>Examples</h2>
|
56
|
-
|
57
|
-
<p>
|
58
|
-
Primarily Rich Units extends Numeric.
|
59
|
-
Here are some basic examples:
|
60
|
-
</p>
|
61
|
-
|
62
|
-
<pre>
|
63
|
-
require 'rich_units'
|
64
|
-
|
65
|
-
4.days.hence #=> Tue Apr 01 08:04:17 -0400 2008
|
66
|
-
4.hours.ago #=> Thu Mar 27 22:03:33 -0400 2008
|
67
|
-
|
68
|
-
10.bytes #=> 80
|
69
|
-
</pre>
|
70
|
-
|
71
|
-
<p>Rich Units also extends Time.</p>
|
72
|
-
|
73
|
-
<pre>
|
74
|
-
require 'rich_units'
|
75
|
-
|
76
|
-
Time.now #=> Fri Mar 28 08:10:40 -0400 2008
|
77
|
-
Time.now.years_hence(4) #=> Wed Mar 28 08:10:47 -0400 2012
|
78
|
-
</pre>
|
79
|
-
|
80
|
-
|
81
|
-
<h2>Installation</h2>
|
82
|
-
|
83
|
-
<p>
|
84
|
-
Installing the RubyGem is of course straight forward.
|
85
|
-
</p>
|
86
|
-
|
87
|
-
<pre>
|
88
|
-
$ sudo gem install rich_units
|
89
|
-
</pre>
|
90
|
-
|
91
|
-
<p>
|
92
|
-
Manual site_ruby installation is provided via <a href="http://setup.rubyforge.org">Ruby Setup</a>.
|
93
|
-
</p>
|
94
|
-
|
95
|
-
<pre>
|
96
|
-
$ tar -xvzf rich_units-0.4.0.tgz
|
97
|
-
$ cd rich_units-0.4.0
|
98
|
-
$ sudo setup.rb all
|
99
|
-
</pre>
|
100
|
-
|
101
|
-
|
102
|
-
<h2>Development</h2>
|
103
|
-
|
104
|
-
<p>You can use gitweb to browse the 'richunits' repository.</p>
|
105
|
-
|
106
|
-
<h3>Anonymous Repository Access</h3>
|
107
|
-
|
108
|
-
<p>To pull the 'richunits' repository anonymously, use:</p>
|
109
|
-
|
110
|
-
<pre>
|
111
|
-
git clone git://rubyforge.org/richunits.git
|
112
|
-
</pre>
|
113
|
-
|
114
|
-
<h3>Master Developer Repository Access</h3>
|
115
|
-
|
116
|
-
<p>Developers: You can push to the 'richunits' repository using:</p>
|
117
|
-
|
118
|
-
<pre>
|
119
|
-
gitosis@rubyforge.org:richunits.git
|
120
|
-
</pre>
|
121
|
-
|
122
|
-
<p>Only project developers have access to this repository.
|
123
|
-
Please contact <b>transfire at gmail.com</b> if you'd like to join the development team.
|
124
|
-
</p>
|
125
|
-
|
126
|
-
<h3>Contributor Repository Access</h3>
|
127
|
-
|
128
|
-
<p>This project is also hosted on GitHub at</p>
|
129
|
-
|
130
|
-
<pre>
|
131
|
-
http://github.com/trans/richunits/tree/master
|
132
|
-
</pre>
|
133
|
-
</div>
|
134
|
-
|
135
|
-
<br/><br/>
|
136
|
-
|
137
|
-
<div style="text-align: center; padding: 20px 0; border-top: 1px solid #ccc;">
|
138
|
-
<script type="text/javascript"><!--
|
139
|
-
google_ad_client = "pub-1126154564663472";
|
140
|
-
/* TIGER 728x90 10/28/08 */
|
141
|
-
google_ad_slot = "2386645975";
|
142
|
-
google_ad_width = 728;
|
143
|
-
google_ad_height = 90;
|
144
|
-
//-->
|
145
|
-
</script>
|
146
|
-
<script type="text/javascript"
|
147
|
-
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
|
148
|
-
</script>
|
149
|
-
<!-- <iframe src="http://tigerops.org/assets/adverts/banner-900-1.html" scrolling="no"></frame> -->
|
150
|
-
</div>
|
151
|
-
|
152
|
-
<div class="copyright">
|
153
|
-
<br/><br/>
|
154
|
-
<span style="color: #EF0040;">Rich Units</span> Copyright (c) 2007, 2008 <a href="http://tigerops.org">Tiger Ops</a>
|
155
|
-
<br/><br/>
|
156
|
-
Rich Units is distributed under the terms of the MIT license. <br/>
|
157
|
-
<br/><br/>
|
158
|
-
</div>
|
159
|
-
|
160
|
-
</div>
|
161
|
-
|
162
|
-
</body>
|
163
|
-
</html>
|