stick 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. data/CHANGES +7 -0
  2. data/COPYING +344 -0
  3. data/README +110 -0
  4. data/lib/stick/constants.rb +3 -0
  5. data/lib/stick/constants/cgs.rb +151 -0
  6. data/lib/stick/constants/mks.rb +158 -0
  7. data/lib/stick/constants/number.rb +33 -0
  8. data/lib/stick/constants/typeless_cgs.rb +141 -0
  9. data/lib/stick/constants/typeless_mks.rb +142 -0
  10. data/lib/stick/currency.rb +8 -0
  11. data/lib/stick/mapcar.rb +61 -0
  12. data/lib/stick/matrix.rb +1022 -0
  13. data/lib/stick/quaternion.rb +562 -0
  14. data/lib/stick/times.rb +441 -0
  15. data/lib/stick/units.rb +112 -0
  16. data/lib/stick/units/base.rb +980 -0
  17. data/lib/stick/units/currency.rb +159 -0
  18. data/lib/stick/units/data/binary/base.rb +4 -0
  19. data/lib/stick/units/data/cex.rb +5 -0
  20. data/lib/stick/units/data/currency-default.rb +5 -0
  21. data/lib/stick/units/data/currency-standard.rb +2 -0
  22. data/lib/stick/units/data/currency/base.rb +89 -0
  23. data/lib/stick/units/data/iec.rb +5 -0
  24. data/lib/stick/units/data/iec_binary/base.rb +6 -0
  25. data/lib/stick/units/data/si.rb +7 -0
  26. data/lib/stick/units/data/si/base.rb +9 -0
  27. data/lib/stick/units/data/si/derived.rb +26 -0
  28. data/lib/stick/units/data/si/extra.rb +22 -0
  29. data/lib/stick/units/data/uk.rb +10 -0
  30. data/lib/stick/units/data/uk/base.rb +22 -0
  31. data/lib/stick/units/data/units-default.rb +11 -0
  32. data/lib/stick/units/data/units-standard.rb +5 -0
  33. data/lib/stick/units/data/us.rb +10 -0
  34. data/lib/stick/units/data/us/base.rb +23 -0
  35. data/lib/stick/units/data/xmethods.rb +5 -0
  36. data/lib/stick/units/data/xmethods/cached.rb +84 -0
  37. data/lib/stick/units/data/xmethods/mapping.rb +87 -0
  38. data/lib/stick/units/loaders.rb +98 -0
  39. data/lib/stick/units/units.rb +109 -0
  40. data/meta/MANIFEST +76 -0
  41. data/meta/ROLLRC +2 -0
  42. data/meta/icli.yaml +16 -0
  43. data/meta/project.yaml +18 -0
  44. data/task/clobber/package +10 -0
  45. data/task/publish +57 -0
  46. data/task/release +10 -0
  47. data/task/setup +1616 -0
  48. data/task/test +25 -0
  49. data/test/spec_matrix.rb +342 -0
  50. data/test/test_currency.rb +26 -0
  51. data/test/test_matrix.rb +359 -0
  52. data/test/test_units.rb +205 -0
  53. data/work/TODO +20 -0
  54. data/work/bytes.rb +231 -0
  55. data/work/multipliers.rb +195 -0
  56. metadata +138 -0
@@ -0,0 +1,195 @@
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
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4.6
3
+ specification_version: 2
4
+ name: stick
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.2.0
7
+ date: 2007-12-14 00:00:00 -05:00
8
+ summary: Stick is an comprehensive science library including a units system providing bot
9
+ require_paths:
10
+ - lib
11
+ email:
12
+ homepage: http://stick.rubyforge.org
13
+ rubyforge_project:
14
+ description: Stick is an comprehensive science library including a units system providing both SI units and web-updated currency units, via a very easy to use method-based interface. It also include a large set of real world contants, provided in "m kg s" and "cm kg s" measures. More science libs are to come.
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc:
19
+ required_ruby_version: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ required_rubygems_version: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: "0"
30
+ version:
31
+ platform: ruby
32
+ signing_key:
33
+ cert_chain: []
34
+
35
+ post_install_message:
36
+ extensions_fallback:
37
+ authors:
38
+ - Peter Vanbroekhoven
39
+ files:
40
+ - test
41
+ - test/test_currency.rb
42
+ - test/test_units.rb
43
+ - test/test_matrix.rb
44
+ - test/unit
45
+ - test/spec_matrix.rb
46
+ - task
47
+ - task/setup
48
+ - task/clobber
49
+ - task/clobber/package
50
+ - task/publish
51
+ - task/test
52
+ - task/release
53
+ - lib
54
+ - lib/stick
55
+ - lib/stick/times.rb
56
+ - lib/stick/units.rb
57
+ - lib/stick/quaternion.rb
58
+ - lib/stick/constants.rb
59
+ - lib/stick/constants
60
+ - lib/stick/constants/mks.rb
61
+ - lib/stick/constants/cgs.rb
62
+ - lib/stick/constants/typeless_mks.rb
63
+ - lib/stick/constants/number.rb
64
+ - lib/stick/constants/typeless_cgs.rb
65
+ - lib/stick/currency.rb
66
+ - lib/stick/units
67
+ - lib/stick/units/currency.rb
68
+ - lib/stick/units/units.rb
69
+ - lib/stick/units/data
70
+ - lib/stick/units/data/uk
71
+ - lib/stick/units/data/uk/base.rb
72
+ - lib/stick/units/data/binary
73
+ - lib/stick/units/data/binary/base.rb
74
+ - lib/stick/units/data/us
75
+ - lib/stick/units/data/us/base.rb
76
+ - lib/stick/units/data/currency
77
+ - lib/stick/units/data/currency/base.rb
78
+ - lib/stick/units/data/xmethods
79
+ - lib/stick/units/data/xmethods/cached.rb
80
+ - lib/stick/units/data/xmethods/mapping.rb
81
+ - lib/stick/units/data/iec_binary
82
+ - lib/stick/units/data/iec_binary/base.rb
83
+ - lib/stick/units/data/si
84
+ - lib/stick/units/data/si/derived.rb
85
+ - lib/stick/units/data/si/extra.rb
86
+ - lib/stick/units/data/si/base.rb
87
+ - lib/stick/units/data/xmethods.rb
88
+ - lib/stick/units/data/uk.rb
89
+ - lib/stick/units/data/cex.rb
90
+ - lib/stick/units/data/us.rb
91
+ - lib/stick/units/data/units-default.rb
92
+ - lib/stick/units/data/currency-standard.rb
93
+ - lib/stick/units/data/units-standard.rb
94
+ - lib/stick/units/data/iec.rb
95
+ - lib/stick/units/data/si.rb
96
+ - lib/stick/units/data/currency-default.rb
97
+ - lib/stick/units/loaders.rb
98
+ - lib/stick/units/base.rb
99
+ - lib/stick/matrix.rb
100
+ - lib/stick/mapcar.rb
101
+ - CHANGES
102
+ - COPYING
103
+ - work
104
+ - work/bytes.rb
105
+ - work/TODO
106
+ - work/multipliers.rb
107
+ - meta
108
+ - meta/MANIFEST
109
+ - meta/ROLLRC
110
+ - meta/project.yaml
111
+ - meta/icli.yaml
112
+ - README
113
+ test_files:
114
+ - test/test_currency.rb
115
+ - test/test_units.rb
116
+ - test/test_matrix.rb
117
+ - test/unit
118
+ - test/spec_matrix.rb
119
+ rdoc_options: []
120
+
121
+ extra_rdoc_files: []
122
+
123
+ executables: []
124
+
125
+ extensions: []
126
+
127
+ requirements: []
128
+
129
+ dependencies:
130
+ - !ruby/object:Gem::Dependency
131
+ name: facets
132
+ version_requirement:
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: 2.1.0
138
+ version: