stick 1.2.0 → 1.3.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.
- data/README +31 -42
- data/RELEASE +29 -0
- data/lib/stick/constants/cgs.rb +2 -2
- data/lib/stick/constants/typeless.rb +3 -0
- data/lib/stick/currency.rb +2 -0
- data/lib/stick/units.rb +5 -1
- data/lib/stick/units/base.rb +90 -89
- data/lib/stick/units/currency.rb +10 -9
- data/lib/stick/units/loaders.rb +3 -1
- data/lib/stick/units/units.rb +2 -0
- data/meta/MANIFEST +2 -0
- data/meta/ROLLRC +1 -1
- data/meta/project.yaml +1 -1
- data/test/test_currency.rb +1 -1
- data/test/test_units.rb +1 -1
- metadata +4 -6
- data/work/TODO +0 -20
- data/work/bytes.rb +0 -231
- data/work/multipliers.rb +0 -195
data/lib/stick/units/currency.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'stick/units/base'
|
2
|
-
|
3
2
|
require 'soap/wsdlDriver'
|
4
3
|
|
5
4
|
module Stick
|
5
|
+
module Units
|
6
6
|
|
7
7
|
class CurrencyLoader < Loader
|
8
8
|
|
@@ -10,14 +10,14 @@ module Stick
|
|
10
10
|
|
11
11
|
def ce_service(converter, name, &blk)
|
12
12
|
old_service = Thread.current[:'Stick::ce_service']
|
13
|
-
Thread.current[:'Stick::ce_service'] = ::Stick::Converter::ExchangeRate.const_get(name)
|
13
|
+
Thread.current[:'Stick::Units::ce_service'] = ::Stick::Units::Converter::ExchangeRate.const_get(name)
|
14
14
|
yield
|
15
15
|
ensure
|
16
|
-
Thread.current[:'Stick::ce_service'] = old_service
|
16
|
+
Thread.current[:'Stick::Units::ce_service'] = old_service
|
17
17
|
end
|
18
18
|
|
19
19
|
def currency_unit(converter, name)
|
20
|
-
service = Thread.current[:'Stick::ce_service'] || ::Stick::Config::DEFAULT_CURRENCY_SERVICE
|
20
|
+
service = Thread.current[:'Stick::Units::ce_service'] || ::Stick::Units::Config::DEFAULT_CURRENCY_SERVICE
|
21
21
|
converter.send(:register_unit, name, :equals => service.create_conversion(name, converter))
|
22
22
|
end
|
23
23
|
|
@@ -36,11 +36,11 @@ module Stick
|
|
36
36
|
# The only subclasses provided are currently XMethods and CachedXMethods.
|
37
37
|
#
|
38
38
|
# To be found automatically from YAML files, exchange services should
|
39
|
-
# be located under Stick::Converter::ExchangeRate.
|
39
|
+
# be located under Stick::Units::Converter::ExchangeRate.
|
40
40
|
class ExchangeRate
|
41
41
|
|
42
42
|
def self.create_conversion(curr, converter) # :nodoc:
|
43
|
-
{:unit => ::Stick::Unit.new({:'--base-currency--' => 1}, converter), :multiplier => self.new(curr)}
|
43
|
+
{:unit => ::Stick::Units::Unit.new({:'--base-currency--' => 1}, converter), :multiplier => self.new(curr)}
|
44
44
|
end
|
45
45
|
|
46
46
|
def initialize(curr) # :nodoc:
|
@@ -104,7 +104,7 @@ module Stick
|
|
104
104
|
private
|
105
105
|
|
106
106
|
def data
|
107
|
-
@@data ||= eval(File.read(File.join(::Stick::Config::CONFIGDIR, 'xmethods', 'mapping.rb')))
|
107
|
+
@@data ||= eval(File.read(File.join(::Stick::Units::Config::CONFIGDIR, 'xmethods', 'mapping.rb')))
|
108
108
|
end
|
109
109
|
|
110
110
|
def country_mapping
|
@@ -133,7 +133,7 @@ module Stick
|
|
133
133
|
private
|
134
134
|
|
135
135
|
def data
|
136
|
-
@@data ||= eval(File.read(File.join(::Stick::Config::CONFIGDIR, 'xmethods', 'cached.rb')))
|
136
|
+
@@data ||= eval(File.read(File.join(::Stick::Units::Config::CONFIGDIR, 'xmethods', 'cached.rb')))
|
137
137
|
end
|
138
138
|
|
139
139
|
end #class CachedXMethods
|
@@ -153,7 +153,8 @@ module Stick
|
|
153
153
|
# Contains some configuration related constants
|
154
154
|
module Config
|
155
155
|
# The standard service used for looking up currency exchange rates
|
156
|
-
DEFAULT_CURRENCY_SERVICE = ::Stick::Converter::ExchangeRate::XMethods
|
156
|
+
DEFAULT_CURRENCY_SERVICE = ::Stick::Units::Converter::ExchangeRate::XMethods
|
157
157
|
end
|
158
158
|
|
159
159
|
end
|
160
|
+
end
|
data/lib/stick/units/loaders.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module Stick
|
2
|
+
module Units
|
2
3
|
|
3
4
|
class Loader
|
4
5
|
|
@@ -73,7 +74,7 @@ module Stick
|
|
73
74
|
end
|
74
75
|
|
75
76
|
def load_config(file, context)
|
76
|
-
data = File.read(File.join(::Stick::Config::CONFIGDIR, file)) rescue File.read(file)
|
77
|
+
data = File.read(File.join(::Stick::Units::Config::CONFIGDIR, file)) rescue File.read(file)
|
77
78
|
context.instance_eval { eval data, nil, file }
|
78
79
|
end
|
79
80
|
|
@@ -96,3 +97,4 @@ module Stick
|
|
96
97
|
end
|
97
98
|
|
98
99
|
end
|
100
|
+
end
|
data/lib/stick/units/units.rb
CHANGED
data/meta/MANIFEST
CHANGED
@@ -2,12 +2,14 @@
|
|
2
2
|
CHANGES
|
3
3
|
COPYING
|
4
4
|
README
|
5
|
+
RELEASE
|
5
6
|
lib
|
6
7
|
lib/stick
|
7
8
|
lib/stick/constants
|
8
9
|
lib/stick/constants/cgs.rb
|
9
10
|
lib/stick/constants/mks.rb
|
10
11
|
lib/stick/constants/number.rb
|
12
|
+
lib/stick/constants/typeless.rb
|
11
13
|
lib/stick/constants/typeless_cgs.rb
|
12
14
|
lib/stick/constants/typeless_mks.rb
|
13
15
|
lib/stick/constants.rb
|
data/meta/ROLLRC
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
stick 1.
|
1
|
+
stick 1.3.0 stable 2007-12-11
|
2
2
|
lib/stick
|
data/meta/project.yaml
CHANGED
data/test/test_currency.rb
CHANGED
data/test/test_units.rb
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4.6
|
|
3
3
|
specification_version: 2
|
4
4
|
name: stick
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.
|
7
|
-
date: 2007-12-
|
6
|
+
version: 1.3.0
|
7
|
+
date: 2007-12-15 00:00:00 -05:00
|
8
8
|
summary: Stick is an comprehensive science library including a units system providing bot
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/stick/constants/typeless_mks.rb
|
63
63
|
- lib/stick/constants/number.rb
|
64
64
|
- lib/stick/constants/typeless_cgs.rb
|
65
|
+
- lib/stick/constants/typeless.rb
|
65
66
|
- lib/stick/currency.rb
|
66
67
|
- lib/stick/units
|
67
68
|
- lib/stick/units/currency.rb
|
@@ -100,16 +101,13 @@ files:
|
|
100
101
|
- lib/stick/mapcar.rb
|
101
102
|
- CHANGES
|
102
103
|
- COPYING
|
103
|
-
- work
|
104
|
-
- work/bytes.rb
|
105
|
-
- work/TODO
|
106
|
-
- work/multipliers.rb
|
107
104
|
- meta
|
108
105
|
- meta/MANIFEST
|
109
106
|
- meta/ROLLRC
|
110
107
|
- meta/project.yaml
|
111
108
|
- meta/icli.yaml
|
112
109
|
- README
|
110
|
+
- RELEASE
|
113
111
|
test_files:
|
114
112
|
- test/test_currency.rb
|
115
113
|
- test/test_units.rb
|
data/work/TODO
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
= To Do List -- Stick
|
2
|
-
|
3
|
-
== Current
|
4
|
-
|
5
|
-
* times.rb mainly serves as a reminder that it would be nice if the units
|
6
|
-
system could have an extra set of conversions for handling calander nomencalture.
|
7
|
-
Of course times.rb can be used too, it's just not really inteded to be used
|
8
|
-
alonde side units.rb.
|
9
|
-
|
10
|
-
== Pre-Stick List
|
11
|
-
|
12
|
-
file://lib/facets/bytes.rb
|
13
|
-
* TODO Currently kilo, mega, etc. are all powers of two and not ten,
|
14
|
-
which technically isn't corrent even though it is common usage. (30)
|
15
|
-
* TODO The in_* notation is weak. If a better nomentclature is thought
|
16
|
-
of then consider changing this. (33)
|
17
|
-
|
18
|
-
file://lib/facets/times.rb
|
19
|
-
* TODO Extra Add in_* methods, like in_days, in_hours, etc. (35)
|
20
|
-
|
data/work/bytes.rb
DELETED
@@ -1,231 +0,0 @@
|
|
1
|
-
# = bytes.rb
|
2
|
-
#
|
3
|
-
# == Copyright (c) 2005 Rich Kilmer, Thomas Sawyer
|
4
|
-
#
|
5
|
-
# Ruby License
|
6
|
-
#
|
7
|
-
# This module is free software. You may use, modify, and/or redistribute this
|
8
|
-
# software under the same terms as Ruby.
|
9
|
-
#
|
10
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
11
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
-
# FOR A PARTICULAR PURPOSE.
|
13
|
-
#
|
14
|
-
# == Special Thanks
|
15
|
-
#
|
16
|
-
# Special thanks to Richard Kilmer for the orignal work.
|
17
|
-
# This library is based on the original library bytes.rb
|
18
|
-
# Copyright (c) 2004 by Rich Kilmer.
|
19
|
-
#
|
20
|
-
# Also thanks to Alexander Kellett for suggesting it be
|
21
|
-
# included in Facets.
|
22
|
-
#
|
23
|
-
# == Authors and Contributors
|
24
|
-
#
|
25
|
-
# * Rich Kilmer
|
26
|
-
# * Thomas Sawyer
|
27
|
-
#
|
28
|
-
# == Developer Notes
|
29
|
-
#
|
30
|
-
# TODO Currently kilo, mega, etc. are all powers of two and not ten,
|
31
|
-
# which technically isn't corrent even though it is common usage.
|
32
|
-
#
|
33
|
-
# TODO The in_* notation is weak. If a better nomentclature is thought
|
34
|
-
# of then consider changing this.
|
35
|
-
|
36
|
-
# Author:: Rich Kilmer, Thomas Sawyer
|
37
|
-
# Copyright:: Copyright (c) 2005 Thomas Sawyer, Rich Kilmer
|
38
|
-
# License:: Ruby License
|
39
|
-
|
40
|
-
# = Binary Multipliers
|
41
|
-
#
|
42
|
-
# Additional methods for Numeric class to make working with
|
43
|
-
# bits and bytes easier. Bits are used as the base value and
|
44
|
-
# these methods can be used to convert between different
|
45
|
-
# magnitudes.
|
46
|
-
#
|
47
|
-
# == Synopisis
|
48
|
-
#
|
49
|
-
# 1.byte #=> 8
|
50
|
-
# 2.bytes #=> 16
|
51
|
-
# 1.kilobit #=> 1024
|
52
|
-
# 1.kilobyte #=> 8192
|
53
|
-
#
|
54
|
-
# Use the in_* methods to perform the inverse operations.
|
55
|
-
#
|
56
|
-
# 8192.in_kilobytes #=> 1
|
57
|
-
# 1024.in_kilobits #=> 1
|
58
|
-
#
|
59
|
-
|
60
|
-
class Numeric
|
61
|
-
|
62
|
-
def bit ; self ; end
|
63
|
-
def bits ; self ; end
|
64
|
-
def byte ; self * 8 ; end
|
65
|
-
def bytes ; self * 8 ; end
|
66
|
-
|
67
|
-
[ 'kilo', 'mega', 'giga', 'tera', 'peta', 'exa' ].each_with_index do |m, i|
|
68
|
-
j = i + 1
|
69
|
-
class_eval %{
|
70
|
-
def #{m}bit ; self * #{1024**j} ; end
|
71
|
-
def #{m}byte ; self * #{1024**j*8} ; end
|
72
|
-
def in_#{m}bits ; self / #{1024**j} ; end
|
73
|
-
def in_#{m}bytes ; self / #{1024**j*8} ; end
|
74
|
-
alias_method :#{m}bits, :#{m}bit
|
75
|
-
alias_method :#{m}bytes, :#{m}byte
|
76
|
-
}
|
77
|
-
end
|
78
|
-
|
79
|
-
[ 'kibi', 'mebi', 'gibi', 'tebi', 'pebi', 'exbi' ].each_with_index do |m, i|
|
80
|
-
j = i + 1
|
81
|
-
class_eval %{
|
82
|
-
def #{m}bit ; self * #{1024**j} ; end
|
83
|
-
def #{m}byte ; self * #{1024**j*8} ; end
|
84
|
-
def in_#{m}bits ; self / #{1024**j} ; end
|
85
|
-
def in_#{m}bytes ; self / #{1024**j*8} ; end
|
86
|
-
alias_method :#{m}bits, :#{m}bit
|
87
|
-
alias_method :#{m}bytes, :#{m}byte
|
88
|
-
}
|
89
|
-
end
|
90
|
-
|
91
|
-
# Formated string of bits proportial to size.
|
92
|
-
#
|
93
|
-
# 1024.bits_to_s #=> "1.00 kb"
|
94
|
-
# 1048576.bits_to_s #=> "1.00 mb"
|
95
|
-
# 1073741824.bits_to_s #=> "1.00 gb"
|
96
|
-
# 1099511627776.bits_to_s #=> "1.00 tb"
|
97
|
-
#
|
98
|
-
# Takes a format string to adjust output.
|
99
|
-
#
|
100
|
-
# 1024.bits_to_s('%.0f') #=> "1 kb"
|
101
|
-
#
|
102
|
-
def strfbits(fmt='%.2f')
|
103
|
-
case
|
104
|
-
when self < 1024
|
105
|
-
"#{self} bits"
|
106
|
-
when self < 1024**2
|
107
|
-
"#{fmt % (self.to_f / 1024)} kb"
|
108
|
-
when self < 1024**3
|
109
|
-
"#{fmt % (self.to_f / 1024**2)} mb"
|
110
|
-
when self < 1024**4
|
111
|
-
"#{fmt % (self.to_f / 1024**3)} gb"
|
112
|
-
when self < 1024**5
|
113
|
-
"#{fmt % (self.to_f / 1024**4)} tb"
|
114
|
-
else
|
115
|
-
"#{self} bits"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
# Formated string of bytes proportial to size.
|
120
|
-
#
|
121
|
-
# 1024.bytes_to_s #=> "1.00 KB"
|
122
|
-
# 1048576.bytes_to_s #=> "1.00 MB"
|
123
|
-
# 1073741824.bytes_to_s #=> "1.00 GB"
|
124
|
-
# 1099511627776.bytes_to_s #=> "1.00 TB"
|
125
|
-
#
|
126
|
-
# Takes a format string to adjust output.
|
127
|
-
#
|
128
|
-
# 1024.bytes_to_s('%.0f') #=> "1 KB"
|
129
|
-
#
|
130
|
-
def strfbytes(fmt='%.2f')
|
131
|
-
case
|
132
|
-
when self < 1024
|
133
|
-
"#{self} bytes"
|
134
|
-
when self < 1024**2
|
135
|
-
"#{fmt % (self.to_f / 1024)} KB"
|
136
|
-
when self < 1024**3
|
137
|
-
"#{fmt % (self.to_f / 1024**2)} MB"
|
138
|
-
when self < 1024**4
|
139
|
-
"#{fmt % (self.to_f / 1024**3)} GB"
|
140
|
-
when self < 1024**5
|
141
|
-
"#{fmt % (self.to_f / 1024**4)} TB"
|
142
|
-
else
|
143
|
-
"#{self} bytes"
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
# deprecated
|
148
|
-
alias_method :octet_units, :strfbytes
|
149
|
-
|
150
|
-
end
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
# _____ _
|
155
|
-
# |_ _|__ ___| |_
|
156
|
-
# | |/ _ \/ __| __|
|
157
|
-
# | | __/\__ \ |_
|
158
|
-
# |_|\___||___/\__|
|
159
|
-
#
|
160
|
-
|
161
|
-
=begin testing
|
162
|
-
|
163
|
-
require 'test/unit'
|
164
|
-
|
165
|
-
class TC_Numeric < Test::Unit::TestCase
|
166
|
-
|
167
|
-
# bits
|
168
|
-
|
169
|
-
def test_bits
|
170
|
-
assert_equal( 8, 8.bits )
|
171
|
-
end
|
172
|
-
|
173
|
-
def test_kilobits
|
174
|
-
assert_equal( 1024**1, 1.kilobit )
|
175
|
-
end
|
176
|
-
|
177
|
-
def test_megabits
|
178
|
-
assert_equal( 1024**2, 1.megabit )
|
179
|
-
end
|
180
|
-
|
181
|
-
def test_gigabits
|
182
|
-
assert_equal( 1024**3, 1.gigabit )
|
183
|
-
end
|
184
|
-
|
185
|
-
def test_terabits
|
186
|
-
assert_equal( 1024**4, 1.terabit )
|
187
|
-
end
|
188
|
-
|
189
|
-
# bytes
|
190
|
-
|
191
|
-
def test_bytes
|
192
|
-
assert_equal( 8192, 1024.bytes )
|
193
|
-
end
|
194
|
-
|
195
|
-
def test_kilobytes
|
196
|
-
assert_equal( 1024**1*8, 1.kilobyte )
|
197
|
-
end
|
198
|
-
|
199
|
-
def test_megabytes
|
200
|
-
assert_equal( 1024**2*8, 1.megabyte )
|
201
|
-
end
|
202
|
-
|
203
|
-
def test_gigabytes
|
204
|
-
assert_equal( 1024**3*8, 1.gigabyte )
|
205
|
-
end
|
206
|
-
|
207
|
-
def test_terabytes
|
208
|
-
assert_equal( 1024**4*8, 1.terabyte )
|
209
|
-
end
|
210
|
-
|
211
|
-
# bits_to_s
|
212
|
-
|
213
|
-
def test_strfbits
|
214
|
-
assert_equal( "1.00 kb", 1024.strfbits )
|
215
|
-
assert_equal( "1.00 mb", 1048576.strfbits )
|
216
|
-
assert_equal( "1.00 gb", 1073741824.strfbits )
|
217
|
-
assert_equal( "1.00 tb", 1099511627776.strfbits )
|
218
|
-
end
|
219
|
-
|
220
|
-
# bytes_to_s
|
221
|
-
|
222
|
-
def test_strfbytes
|
223
|
-
assert_equal( "1.00 KB", 1024.strfbytes )
|
224
|
-
assert_equal( "1.00 MB", 1048576.strfbytes )
|
225
|
-
assert_equal( "1.00 GB", 1073741824.strfbytes )
|
226
|
-
assert_equal( "1.00 TB", 1099511627776.strfbytes )
|
227
|
-
end
|
228
|
-
|
229
|
-
end
|
230
|
-
|
231
|
-
=end
|
data/work/multipliers.rb
DELETED
@@ -1,195 +0,0 @@
|
|
1
|
-
# = multipliers.rb
|
2
|
-
#
|
3
|
-
# == Copyright (c) 2005 Thomas Sawyer
|
4
|
-
#
|
5
|
-
# Ruby License
|
6
|
-
#
|
7
|
-
# This module is free software. You may use, modify, and/or redistribute this
|
8
|
-
# software under the same terms as Ruby.
|
9
|
-
#
|
10
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
11
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
-
# FOR A PARTICULAR PURPOSE.
|
13
|
-
#
|
14
|
-
# == Special Thanks
|
15
|
-
#
|
16
|
-
# Thanks to Rich Kilmer and bytes.rb which inspired this library.
|
17
|
-
#
|
18
|
-
# == Author(s)
|
19
|
-
#
|
20
|
-
# * Thomas Sawyer
|
21
|
-
|
22
|
-
# Author:: Thomas Sawyer
|
23
|
-
# Copyright:: Copyright (c) 2005 Thomas Sawyer
|
24
|
-
# License:: Ruby License
|
25
|
-
|
26
|
-
# = Multipliers
|
27
|
-
#
|
28
|
-
# Adds methods to Numeric to make working with
|
29
|
-
# magnitudes (kilo, mega, giga, milli, micro, etc.)
|
30
|
-
# as well as bits and bytes easier.
|
31
|
-
#
|
32
|
-
# 1.kilo #=> 1000
|
33
|
-
# 1.milli #=> 0.001
|
34
|
-
# 1.kibi #=> 1024
|
35
|
-
#
|
36
|
-
# To display a value in a certain denomination, simply
|
37
|
-
# perform the inverse operation by placing the
|
38
|
-
# multiplier called on unit (1) in the denominator.
|
39
|
-
#
|
40
|
-
# 1000 / 1.kilo #=> 1
|
41
|
-
# 1024 / 1.kibi #=> 1
|
42
|
-
#
|
43
|
-
|
44
|
-
class Numeric
|
45
|
-
|
46
|
-
# SI Multipliers
|
47
|
-
|
48
|
-
def deka ; self * 10 ; end
|
49
|
-
def hecto ; self * 100 ; end
|
50
|
-
def kilo ; self * 1000 ; end
|
51
|
-
def mega ; self * 1000000 ; end
|
52
|
-
def giga ; self * 1000000000 ; end
|
53
|
-
def tera ; self * 1000000000000 ; end
|
54
|
-
def peta ; self * 1000000000000000 ; end
|
55
|
-
def exa ; self * 1000000000000000000 ; end
|
56
|
-
|
57
|
-
# SI Fractional
|
58
|
-
|
59
|
-
def deci ; self.to_f / 10 ; end
|
60
|
-
def centi ; self.to_f / 100 ; end
|
61
|
-
def milli ; self.to_f / 1000 ; end
|
62
|
-
def micro ; self.to_f / 1000000 ; end
|
63
|
-
def nano ; self.to_f / 1000000000 ; end
|
64
|
-
def pico ; self.to_f / 1000000000000 ; end
|
65
|
-
def femto ; self.to_f / 1000000000000000 ; end
|
66
|
-
def atto ; self.to_f / 1000000000000000000 ; end
|
67
|
-
|
68
|
-
# SI Binary
|
69
|
-
|
70
|
-
def kibi ; self * 1024 ; end
|
71
|
-
def mebi ; self * 1024**2 ; end
|
72
|
-
def gibi ; self * 1024**3 ; end
|
73
|
-
def tebi ; self * 1024**4 ; end
|
74
|
-
def pebi ; self * 1024**5 ; end
|
75
|
-
def exbi ; self * 1024**6 ; end
|
76
|
-
|
77
|
-
# Bits and Bytes
|
78
|
-
|
79
|
-
def bit ; self ; end
|
80
|
-
def bits ; self ; end
|
81
|
-
def byte ; self * 8 ; end
|
82
|
-
def bytes ; self * 8 ; end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
# _____ _
|
89
|
-
# |_ _|__ ___| |_
|
90
|
-
# | |/ _ \/ __| __|
|
91
|
-
# | | __/\__ \ |_
|
92
|
-
# |_|\___||___/\__|
|
93
|
-
#
|
94
|
-
|
95
|
-
=begin testing
|
96
|
-
|
97
|
-
require 'test/unit'
|
98
|
-
|
99
|
-
class TC_Multipliers < Test::Unit::TestCase
|
100
|
-
|
101
|
-
def test_deka
|
102
|
-
assert_equal( 10, 1.deka )
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_hecto
|
106
|
-
assert_equal( 100, 1.hecto )
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_kilo
|
110
|
-
assert_equal( 1000, 1.kilo )
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_mega
|
114
|
-
assert_equal( 1000000, 1.mega )
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_giga
|
118
|
-
assert_equal( 1000000000, 1.giga )
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_tera
|
122
|
-
assert_equal( 1000000000000, 1.tera )
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_peta
|
126
|
-
assert_equal( 1000000000000000, 1.peta )
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_exa
|
130
|
-
assert_equal( 1000000000000000000, 1.exa )
|
131
|
-
end
|
132
|
-
|
133
|
-
# Fractional
|
134
|
-
|
135
|
-
def test_deci
|
136
|
-
assert_equal( 0.1, 1.deci )
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_centi
|
140
|
-
assert_equal( 0.01, 1.centi )
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_milli
|
144
|
-
assert_equal( 0.001, 1.milli )
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_milli
|
148
|
-
assert_equal( 0.000001, 1.micro )
|
149
|
-
end
|
150
|
-
|
151
|
-
def test_nano
|
152
|
-
assert_equal( 0.000000001, 1.nano )
|
153
|
-
end
|
154
|
-
|
155
|
-
def test_pico
|
156
|
-
assert_equal( 0.000000000001, 1.pico )
|
157
|
-
end
|
158
|
-
|
159
|
-
def test_femto
|
160
|
-
assert_equal( 0.000000000000001, 1.femto )
|
161
|
-
end
|
162
|
-
|
163
|
-
def test_atto
|
164
|
-
assert_equal( 0.000000000000000001, 1.atto )
|
165
|
-
end
|
166
|
-
|
167
|
-
# SI Binary
|
168
|
-
|
169
|
-
def test_kibi
|
170
|
-
assert_equal( 1024, 1.kibi )
|
171
|
-
end
|
172
|
-
|
173
|
-
def test_mebi
|
174
|
-
assert_equal( 1024**2, 1.mebi )
|
175
|
-
end
|
176
|
-
|
177
|
-
def test_gibi
|
178
|
-
assert_equal( 1024**3, 1.gibi )
|
179
|
-
end
|
180
|
-
|
181
|
-
def test_tebi
|
182
|
-
assert_equal( 1024**4, 1.tebi )
|
183
|
-
end
|
184
|
-
|
185
|
-
def test_pebi
|
186
|
-
assert_equal( 1024**5, 1.pebi )
|
187
|
-
end
|
188
|
-
|
189
|
-
def test_exbi
|
190
|
-
assert_equal( 1024**6, 1.exbi )
|
191
|
-
end
|
192
|
-
|
193
|
-
end
|
194
|
-
|
195
|
-
=end
|