sixarm_ruby_numeric_round 1.0.2 → 1.0.4

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 08baa396986b26c7f6bf1ea6faf8fbcccb1b179d
4
+ data.tar.gz: 3a88d8717e728cfd1e0aae6a291df409b2f377a8
5
+ SHA512:
6
+ metadata.gz: 58723800408b15a6bafba51d62761a70ffa398c367c9d34dce75babfcbace4723de7434acd7f24775db94ae2637b8c39fa71b314193c6d34cc35ee707df14fbc
7
+ data.tar.gz: c57962488b5be7e72ca9ecc3148d678f4b652b2c8162c4315f22d8021a5a99e8fb0473855931b4c07cfd353cb480697a3d1ed6a12387a8922fc70b7cf61c8480
Binary file
data.tar.gz.sig CHANGED
Binary file
data/Rakefile CHANGED
@@ -1,8 +1,13 @@
1
1
  # -*- coding: utf-8 -*-
2
- require 'rake'
3
- require 'rake/testtask'
2
+ require "rake"
3
+ require "rake/testtask"
4
4
 
5
5
  Rake::TestTask.new(:test) do |t|
6
- t.libs << 'lib' << 'test'
7
- t.pattern = 'test/*.rb'
6
+ t.libs.push("lib", "test")
7
+ t.pattern = "test/**/*.rb"
8
8
  end
9
+
10
+ task :default => [:test]
11
+ task :default => [:test]
12
+ task :default => [:test]
13
+ task :default => [:test]
@@ -3,182 +3,5 @@
3
3
  Please see README
4
4
  =end
5
5
 
6
- class Numeric
7
-
8
- # Conceptually, ceil is expected to apply to floating point numbers.
9
- # However it can actually be applied to pretty much any Numeric object.
10
- # For example, one could ceil an Integer to the nearest kilo.
11
- #
12
- # See Float#ceil_at.
13
-
14
- def ceil_at(*args)
15
- to_f.ceil_at(*args)
16
- end
17
-
18
- # See Float#ceil_to.
19
-
20
- def ceil_to(*args)
21
- to_f.ceil_to(*args)
22
- end
23
-
24
- # Conceptually, floor is expected to apply to floating point numbers.
25
- # However it can actually be applied to pretty much any Numeric object.
26
- # For example, one could floor an Integer to the nearest kilo.
27
- #
28
- # See Float#floor_at.
29
-
30
- def floor_at(*args)
31
- to_f.floor_at(*args)
32
- end
33
-
34
- # See Float#floor_to.
35
-
36
- def floor_to(*args)
37
- to_f.floor_to(*args)
38
- end
39
-
40
- # Conceptually, round is expected to apply to floating point numbers.
41
- # However it can actually be applied to pretty much any Numeric object.
42
- # For example, one could round an Integer to the nearest kilo.
43
- #
44
- # See Float#round_at.
45
-
46
- def round_at(*args)
47
- to_f.round_at(*args)
48
- end
49
-
50
- # See Float#round_to.
51
-
52
- def round_to(*args)
53
- to_f.round_to(*args)
54
- end
55
-
56
- # Conceptually, truncate is expected to apply to floating point numbers.
57
- # However it can actually be applied to pretty much any Numeric object.
58
- # For example, one could truncate an Integer to the nearest kilo.
59
- #
60
- # See Float#truncate_at.
61
-
62
- def truncate_at(*args)
63
- to_f.truncate_at(*args)
64
- end
65
-
66
- # See Float#truncate_to.
67
-
68
- def truncate_to(*args)
69
- to_f.truncate_to(*args)
70
- end
71
-
72
- end
73
-
74
- class Float
75
-
76
- # Ceil to the given decimal position.
77
- #
78
- # 4.555.ceil_at(0) #=> 5.0
79
- # 4.555.ceil_at(1) #=> 4.6
80
- # 4.555.ceil_at(2) #=> 4.56
81
- # 4.555.ceil_at(3) #=> 4.555
82
- #
83
- # CREDIT: Trans & Joel Parker Henderson
84
-
85
- def ceil_at( d ) #d=0
86
- (self * (10 ** d)).ceil.fdiv (10 ** d)
87
- end
88
-
89
- # Ceils to the nearest _n_th degree.
90
- #
91
- # 4.555.ceil_to(1) #=> 5.0
92
- # 4.555.ceil_to(0.1) #=> 4.6
93
- # 4.555.ceil_to(0.01) #=> 4.56
94
- # 4.555.ceil_to(0) #=> 4.555
95
- #
96
- # CREDIT: Trans & Joel Parker Henderson
97
-
98
- def ceil_to( n ) #n=1
99
- return self if n == 0
100
- (self * (1.0 / n)).ceil.fdiv (1.0 / n)
101
- end
102
-
103
- # Floor to the given decimal position.
104
- #
105
- # 4.555.floor_at(0) #=> 4.0
106
- # 4.555.floor_at(1) #=> 4.5
107
- # 4.555.floor_at(2) #=> 4.55
108
- # 4.555.floor_at(3) #=> 4.555
109
- #
110
- # CREDIT: Trans & Joel Parker Henderson
111
-
112
- def floor_at( d ) #d=0
113
- (self * (10 ** d)).floor.fdiv (10 ** d)
114
- end
115
-
116
- # Floors to the nearest _n_th degree.
117
- #
118
- # 4.555.floor_to(1) #=> 4.0
119
- # 4.555.floor_to(0.1) #=> 4.5
120
- # 4.555.floor_to(0.01) #=> 4.55
121
- # 4.555.floor_to(0) #=> 4.555
122
- #
123
- # CREDIT: Trans & Joel Parker Henderson
124
-
125
- def floor_to( n ) #n=1
126
- return self if n == 0
127
- (self * (1.0 / n)).floor.fdiv (1.0 / n)
128
- end
129
-
130
- # Round to the given decimal position.
131
- #
132
- # 4.555.round_at(0) #=> 5.0
133
- # 4.555.round_at(1) #=> 4.6
134
- # 4.555.round_at(2) #=> 4.56
135
- # 4.555.round_at(3) #=> 4.555
136
- #
137
- # CREDIT: Trans & Joel Parker Henderson
138
-
139
- def round_at( d ) #d=0
140
- (self * (10 ** d)).round.fdiv (10 ** d)
141
- end
142
-
143
- # Rounds to the nearest _n_th degree.
144
- #
145
- # 4.555.round_to(1) #=> 5
146
- # 4.555.round_to(0.1) #=> 4.6
147
- # 4.555.round_to(0.01) #=> 4.56
148
- # 4.555.round_to(0) #=> 4.555
149
- #
150
- # CREDIT: Trans & Joel Parker Henderson
151
-
152
- def round_to( n ) #n=1
153
- return self if n == 0
154
- (self * (1.0 / n)).round.fdiv (1.0 / n)
155
- end
156
-
157
- # Truncate to the given decimal position.
158
- #
159
- # 4.555.truncate_at(0) #=> 4.0
160
- # 4.555.truncate_at(1) #=> 4.5
161
- # 4.555.truncate_at(2) #=> 4.55
162
- # 4.555.truncate_at(3) #=> 4.555
163
- #
164
- # CREDIT: Trans & Joel Parker Henderson
165
-
166
- def truncate_at( d ) #d=0
167
- (self * (10 ** d)).truncate.fdiv (10 ** d)
168
- end
169
-
170
- # Truncates to the nearest _n_th degree.
171
- #
172
- # 4.555.truncate_to(1) #=> 4.0
173
- # 4.555.truncate_to(0.1) #=> 4.5
174
- # 4.555.truncate_to(0.01) #=> 4.55
175
- # 4.555.truncate_to(0) #=> 4.555
176
- #
177
- # CREDIT: Trans & Joel Parker Henderson
178
-
179
- def truncate_to( n ) #n=1
180
- return self if n == 0
181
- (self * (1.0 / n)).truncate.fdiv (1.0 / n)
182
- end
183
-
184
- end
6
+ require_relative "sixarm_ruby_numeric_round/float"
7
+ require_relative "sixarm_ruby_numeric_round/numeric"
@@ -0,0 +1,116 @@
1
+ # -*- coding: utf-8 -*-
2
+ =begin rdoc
3
+ Float extensions to calculate round numbers.
4
+ =end
5
+
6
+ class Float
7
+
8
+ # Ceil to the given decimal position.
9
+ #
10
+ # 4.555.ceil_at(0) #=> 5.0
11
+ # 4.555.ceil_at(1) #=> 4.6
12
+ # 4.555.ceil_at(2) #=> 4.56
13
+ # 4.555.ceil_at(3) #=> 4.555
14
+ #
15
+ # CREDIT: Trans & Joel Parker Henderson
16
+
17
+ def ceil_at( d ) #d=0
18
+ (self * (10 ** d)).ceil.fdiv (10 ** d)
19
+ end
20
+
21
+ # Ceils to the nearest _n_th degree.
22
+ #
23
+ # 4.555.ceil_to(1) #=> 5.0
24
+ # 4.555.ceil_to(0.1) #=> 4.6
25
+ # 4.555.ceil_to(0.01) #=> 4.56
26
+ # 4.555.ceil_to(0) #=> 4.555
27
+ #
28
+ # CREDIT: Trans & Joel Parker Henderson
29
+
30
+ def ceil_to( n ) #n=1
31
+ return self if n == 0
32
+ (self * (1.0 / n)).ceil.fdiv (1.0 / n)
33
+ end
34
+
35
+ # Floor to the given decimal position.
36
+ #
37
+ # 4.555.floor_at(0) #=> 4.0
38
+ # 4.555.floor_at(1) #=> 4.5
39
+ # 4.555.floor_at(2) #=> 4.55
40
+ # 4.555.floor_at(3) #=> 4.555
41
+ #
42
+ # CREDIT: Trans & Joel Parker Henderson
43
+
44
+ def floor_at( d ) #d=0
45
+ (self * (10 ** d)).floor.fdiv (10 ** d)
46
+ end
47
+
48
+ # Floors to the nearest _n_th degree.
49
+ #
50
+ # 4.555.floor_to(1) #=> 4.0
51
+ # 4.555.floor_to(0.1) #=> 4.5
52
+ # 4.555.floor_to(0.01) #=> 4.55
53
+ # 4.555.floor_to(0) #=> 4.555
54
+ #
55
+ # CREDIT: Trans & Joel Parker Henderson
56
+
57
+ def floor_to( n ) #n=1
58
+ return self if n == 0
59
+ (self * (1.0 / n)).floor.fdiv (1.0 / n)
60
+ end
61
+
62
+ # Round to the given decimal position.
63
+ #
64
+ # 4.555.round_at(0) #=> 5.0
65
+ # 4.555.round_at(1) #=> 4.6
66
+ # 4.555.round_at(2) #=> 4.56
67
+ # 4.555.round_at(3) #=> 4.555
68
+ #
69
+ # CREDIT: Trans & Joel Parker Henderson
70
+
71
+ def round_at( d ) #d=0
72
+ (self * (10 ** d)).round.fdiv (10 ** d)
73
+ end
74
+
75
+ # Rounds to the nearest _n_th degree.
76
+ #
77
+ # 4.555.round_to(1) #=> 5
78
+ # 4.555.round_to(0.1) #=> 4.6
79
+ # 4.555.round_to(0.01) #=> 4.56
80
+ # 4.555.round_to(0) #=> 4.555
81
+ #
82
+ # CREDIT: Trans & Joel Parker Henderson
83
+
84
+ def round_to( n ) #n=1
85
+ return self if n == 0
86
+ (self * (1.0 / n)).round.fdiv (1.0 / n)
87
+ end
88
+
89
+ # Truncate to the given decimal position.
90
+ #
91
+ # 4.555.truncate_at(0) #=> 4.0
92
+ # 4.555.truncate_at(1) #=> 4.5
93
+ # 4.555.truncate_at(2) #=> 4.55
94
+ # 4.555.truncate_at(3) #=> 4.555
95
+ #
96
+ # CREDIT: Trans & Joel Parker Henderson
97
+
98
+ def truncate_at( d ) #d=0
99
+ (self * (10 ** d)).truncate.fdiv (10 ** d)
100
+ end
101
+
102
+ # Truncates to the nearest _n_th degree.
103
+ #
104
+ # 4.555.truncate_to(1) #=> 4.0
105
+ # 4.555.truncate_to(0.1) #=> 4.5
106
+ # 4.555.truncate_to(0.01) #=> 4.55
107
+ # 4.555.truncate_to(0) #=> 4.555
108
+ #
109
+ # CREDIT: Trans & Joel Parker Henderson
110
+
111
+ def truncate_to( n ) #n=1
112
+ return self if n == 0
113
+ (self * (1.0 / n)).truncate.fdiv (1.0 / n)
114
+ end
115
+
116
+ end
@@ -0,0 +1,72 @@
1
+ # -*- coding: utf-8 -*-
2
+ =begin rdoc
3
+ Numeric extensions to calculate round numbers.
4
+ =end
5
+
6
+ class Numeric
7
+
8
+ # Conceptually, ceil is expected to apply to floating point numbers.
9
+ # However it can actually be applied to pretty much any Numeric object.
10
+ # For example, one could ceil an Integer to the nearest kilo.
11
+ #
12
+ # See Float#ceil_at.
13
+
14
+ def ceil_at(*args)
15
+ to_f.ceil_at(*args)
16
+ end
17
+
18
+ # See Float#ceil_to.
19
+
20
+ def ceil_to(*args)
21
+ to_f.ceil_to(*args)
22
+ end
23
+
24
+ # Conceptually, floor is expected to apply to floating point numbers.
25
+ # However it can actually be applied to pretty much any Numeric object.
26
+ # For example, one could floor an Integer to the nearest kilo.
27
+ #
28
+ # See Float#floor_at.
29
+
30
+ def floor_at(*args)
31
+ to_f.floor_at(*args)
32
+ end
33
+
34
+ # See Float#floor_to.
35
+
36
+ def floor_to(*args)
37
+ to_f.floor_to(*args)
38
+ end
39
+
40
+ # Conceptually, round is expected to apply to floating point numbers.
41
+ # However it can actually be applied to pretty much any Numeric object.
42
+ # For example, one could round an Integer to the nearest kilo.
43
+ #
44
+ # See Float#round_at.
45
+
46
+ def round_at(*args)
47
+ to_f.round_at(*args)
48
+ end
49
+
50
+ # See Float#round_to.
51
+
52
+ def round_to(*args)
53
+ to_f.round_to(*args)
54
+ end
55
+
56
+ # Conceptually, truncate is expected to apply to floating point numbers.
57
+ # However it can actually be applied to pretty much any Numeric object.
58
+ # For example, one could truncate an Integer to the nearest kilo.
59
+ #
60
+ # See Float#truncate_at.
61
+
62
+ def truncate_at(*args)
63
+ to_f.truncate_at(*args)
64
+ end
65
+
66
+ # See Float#truncate_to.
67
+
68
+ def truncate_to(*args)
69
+ to_f.truncate_to(*args)
70
+ end
71
+
72
+ end
@@ -1,104 +1,11 @@
1
1
  # -*- coding: utf-8 -*-
2
- require 'minitest/autorun'
3
- require 'simplecov'
2
+ require "minitest/autorun"
3
+ require "coveralls"
4
+ require "simplecov"
5
+ Coveralls.wear!
6
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ Coveralls::SimpleCov::Formatter
9
+ ]
4
10
  SimpleCov.start
5
- require 'sixarm_ruby_numeric_round'
6
-
7
- describe Float do
8
-
9
- describe "#ceil_at" do
10
-
11
- it "works" do
12
- 4.555.ceil_at(0).must_equal 5.0
13
- 4.555.ceil_at(1).must_equal 4.6
14
- 4.555.ceil_at(2).must_equal 4.56
15
- 4.555.ceil_at(3).must_equal 4.555
16
- end
17
-
18
- end
19
-
20
- describe "#ceil_to" do
21
-
22
- it "works" do
23
- 4.555.ceil_to(1).must_equal 5.0
24
- 4.555.ceil_to(0.1).must_equal 4.6
25
- 4.555.ceil_to(0.01).must_equal 4.56
26
- 4.555.ceil_to(0).must_equal 4.555
27
- end
28
-
29
- end
30
-
31
- describe "#floor_at" do
32
-
33
- it "works" do
34
- 4.555.floor_at(0).must_equal 4.0
35
- 4.555.floor_at(1).must_equal 4.5
36
- 4.555.floor_at(2).must_equal 4.55
37
- 4.555.floor_at(3).must_equal 4.555
38
- end
39
-
40
- end
41
-
42
- describe "#floor_to" do
43
-
44
- it "works" do
45
- 4.555.floor_to(1).must_equal 4.0
46
- 4.555.floor_to(0.1).must_equal 4.5
47
- 4.555.floor_to(0.01).must_equal 4.55
48
- 4.555.floor_to(0).must_equal 4.555
49
- end
50
-
51
- end
52
-
53
- describe "#round_at" do
54
-
55
- it "works" do
56
- 4.555.round_at(0).must_equal 5.0
57
- 4.555.round_at(1).must_equal 4.6
58
- 4.555.round_at(2).must_equal 4.56
59
- 4.555.round_at(3).must_equal 4.555
60
- end
61
-
62
- end
63
-
64
- describe "#round_to" do
65
-
66
- it "works" do
67
- 4.555.round_to(1).must_equal 5
68
- 4.555.round_to(0.1).must_equal 4.6
69
- 4.555.round_to(0.01).must_equal 4.56
70
- 4.555.round_to(0).must_equal 4.555
71
- end
72
-
73
- end
74
-
75
- describe "#truncate_at" do
76
-
77
- it "works" do
78
- 4.555.truncate_at(0).must_equal 4.0
79
- 4.555.truncate_at(1).must_equal 4.5
80
- 4.555.truncate_at(2).must_equal 4.55
81
- 4.555.truncate_at(3).must_equal 4.555
82
- end
83
-
84
- end
85
-
86
- describe "#truncate_to" do
87
-
88
- it "works" do
89
- 4.555.truncate_to(1).must_equal 4.0
90
- 4.555.truncate_to(0.1).must_equal 4.5
91
- 4.555.truncate_to(0.01).must_equal 4.55
92
- 4.555.truncate_to(0).must_equal 4.555
93
- end
94
-
95
- end
96
-
97
- end
98
-
99
-
100
-
101
-
102
-
103
-
104
-
11
+ require "sixarm_ruby_numeric_round"
@@ -0,0 +1,104 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "minitest/autorun"
3
+ require "simplecov"
4
+ SimpleCov.start
5
+ require "sixarm_ruby_numeric_round"
6
+
7
+ describe Float do
8
+
9
+ describe "#ceil_at" do
10
+
11
+ it "works" do
12
+ 4.555.ceil_at(0).must_equal 5.0
13
+ 4.555.ceil_at(1).must_equal 4.6
14
+ 4.555.ceil_at(2).must_equal 4.56
15
+ 4.555.ceil_at(3).must_equal 4.555
16
+ end
17
+
18
+ end
19
+
20
+ describe "#ceil_to" do
21
+
22
+ it "works" do
23
+ 4.555.ceil_to(1).must_equal 5.0
24
+ 4.555.ceil_to(0.1).must_equal 4.6
25
+ 4.555.ceil_to(0.01).must_equal 4.56
26
+ 4.555.ceil_to(0).must_equal 4.555
27
+ end
28
+
29
+ end
30
+
31
+ describe "#floor_at" do
32
+
33
+ it "works" do
34
+ 4.555.floor_at(0).must_equal 4.0
35
+ 4.555.floor_at(1).must_equal 4.5
36
+ 4.555.floor_at(2).must_equal 4.55
37
+ 4.555.floor_at(3).must_equal 4.555
38
+ end
39
+
40
+ end
41
+
42
+ describe "#floor_to" do
43
+
44
+ it "works" do
45
+ 4.555.floor_to(1).must_equal 4.0
46
+ 4.555.floor_to(0.1).must_equal 4.5
47
+ 4.555.floor_to(0.01).must_equal 4.55
48
+ 4.555.floor_to(0).must_equal 4.555
49
+ end
50
+
51
+ end
52
+
53
+ describe "#round_at" do
54
+
55
+ it "works" do
56
+ 4.555.round_at(0).must_equal 5.0
57
+ 4.555.round_at(1).must_equal 4.6
58
+ 4.555.round_at(2).must_equal 4.56
59
+ 4.555.round_at(3).must_equal 4.555
60
+ end
61
+
62
+ end
63
+
64
+ describe "#round_to" do
65
+
66
+ it "works" do
67
+ 4.555.round_to(1).must_equal 5
68
+ 4.555.round_to(0.1).must_equal 4.6
69
+ 4.555.round_to(0.01).must_equal 4.56
70
+ 4.555.round_to(0).must_equal 4.555
71
+ end
72
+
73
+ end
74
+
75
+ describe "#truncate_at" do
76
+
77
+ it "works" do
78
+ 4.555.truncate_at(0).must_equal 4.0
79
+ 4.555.truncate_at(1).must_equal 4.5
80
+ 4.555.truncate_at(2).must_equal 4.55
81
+ 4.555.truncate_at(3).must_equal 4.555
82
+ end
83
+
84
+ end
85
+
86
+ describe "#truncate_to" do
87
+
88
+ it "works" do
89
+ 4.555.truncate_to(1).must_equal 4.0
90
+ 4.555.truncate_to(0.1).must_equal 4.5
91
+ 4.555.truncate_to(0.01).must_equal 4.55
92
+ 4.555.truncate_to(0).must_equal 4.555
93
+ end
94
+
95
+ end
96
+
97
+ end
98
+
99
+
100
+
101
+
102
+
103
+
104
+
@@ -0,0 +1,104 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "minitest/autorun"
3
+ require "simplecov"
4
+ SimpleCov.start
5
+ require "sixarm_ruby_numeric_round"
6
+
7
+ describe Float do
8
+
9
+ describe "#ceil_at" do
10
+
11
+ it "works" do
12
+ 4.555.ceil_at(0).must_equal 5.0
13
+ 4.555.ceil_at(1).must_equal 4.6
14
+ 4.555.ceil_at(2).must_equal 4.56
15
+ 4.555.ceil_at(3).must_equal 4.555
16
+ end
17
+
18
+ end
19
+
20
+ describe "#ceil_to" do
21
+
22
+ it "works" do
23
+ 4.555.ceil_to(1).must_equal 5.0
24
+ 4.555.ceil_to(0.1).must_equal 4.6
25
+ 4.555.ceil_to(0.01).must_equal 4.56
26
+ 4.555.ceil_to(0).must_equal 4.555
27
+ end
28
+
29
+ end
30
+
31
+ describe "#floor_at" do
32
+
33
+ it "works" do
34
+ 4.555.floor_at(0).must_equal 4.0
35
+ 4.555.floor_at(1).must_equal 4.5
36
+ 4.555.floor_at(2).must_equal 4.55
37
+ 4.555.floor_at(3).must_equal 4.555
38
+ end
39
+
40
+ end
41
+
42
+ describe "#floor_to" do
43
+
44
+ it "works" do
45
+ 4.555.floor_to(1).must_equal 4.0
46
+ 4.555.floor_to(0.1).must_equal 4.5
47
+ 4.555.floor_to(0.01).must_equal 4.55
48
+ 4.555.floor_to(0).must_equal 4.555
49
+ end
50
+
51
+ end
52
+
53
+ describe "#round_at" do
54
+
55
+ it "works" do
56
+ 4.555.round_at(0).must_equal 5.0
57
+ 4.555.round_at(1).must_equal 4.6
58
+ 4.555.round_at(2).must_equal 4.56
59
+ 4.555.round_at(3).must_equal 4.555
60
+ end
61
+
62
+ end
63
+
64
+ describe "#round_to" do
65
+
66
+ it "works" do
67
+ 4.555.round_to(1).must_equal 5
68
+ 4.555.round_to(0.1).must_equal 4.6
69
+ 4.555.round_to(0.01).must_equal 4.56
70
+ 4.555.round_to(0).must_equal 4.555
71
+ end
72
+
73
+ end
74
+
75
+ describe "#truncate_at" do
76
+
77
+ it "works" do
78
+ 4.555.truncate_at(0).must_equal 4.0
79
+ 4.555.truncate_at(1).must_equal 4.5
80
+ 4.555.truncate_at(2).must_equal 4.55
81
+ 4.555.truncate_at(3).must_equal 4.555
82
+ end
83
+
84
+ end
85
+
86
+ describe "#truncate_to" do
87
+
88
+ it "works" do
89
+ 4.555.truncate_to(1).must_equal 4.0
90
+ 4.555.truncate_to(0.1).must_equal 4.5
91
+ 4.555.truncate_to(0.01).must_equal 4.55
92
+ 4.555.truncate_to(0).must_equal 4.555
93
+ end
94
+
95
+ end
96
+
97
+ end
98
+
99
+
100
+
101
+
102
+
103
+
104
+
metadata CHANGED
@@ -1,78 +1,174 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sixarm_ruby_numeric_round
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
5
- prerelease:
4
+ version: 1.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - SixArm
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain:
12
- - !binary |-
13
- LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURCRENDQW0yZ0F3SUJB
14
- Z0lKQUtQd0VFVFU1YkhvTUEwR0NTcUdTSWIzRFFFQkJRVUFNR0F4Q3pBSkJn
15
- TlYKQkFZVEFsVlRNUk13RVFZRFZRUUlFd3BEWVd4cFptOXlibWxoTVJZd0ZB
16
- WURWUVFIRXcxVFlXNGdSbkpoYm1OcApjMk52TVE4d0RRWURWUVFLRXdaVGFY
17
- aEJjbTB4RXpBUkJnTlZCQU1UQ25OcGVHRnliUzVqYjIwd0hoY05NVEF4Ck1q
18
- RXpNak15TnpFeldoY05NVE13T1RBNE1qTXlOekV6V2pCZ01Rc3dDUVlEVlFR
19
- R0V3SlZVekVUTUJFR0ExVUUKQ0JNS1EyRnNhV1p2Y201cFlURVdNQlFHQTFV
20
- RUJ4TU5VMkZ1SUVaeVlXNWphWE5qYnpFUE1BMEdBMVVFQ2hNRwpVMmw0UVhK
21
- dE1STXdFUVlEVlFRREV3cHphWGhoY20wdVkyOXRNSUdmTUEwR0NTcUdTSWIz
22
- RFFFQkFRVUFBNEdOCkFEQ0JpUUtCZ1FDOTRtRDlKRHdCc3Vuc09JMFZSM0NY
23
- WGJPV2c5Y1dhV2Npd0Z5Sk5GaU03QTlJOEtQTGZYVXcKUUM0Y3pVZTVadUc0
24
- V0h2aW5yV2hrckNLKzFkV0Jxb0VDbHhkRi9Gb0tPNWErdG9uR0Nqam1meTgx
25
- Sm1Gamp5eAplVHNqc0h5dncrUWlrOWtwZjlhajYrcG5rTnJWc3dnTkhWZWEy
26
- bzl5YWJiRWlTNlZTZUpXb1FJREFRQUJvNEhGCk1JSENNQjBHQTFVZERnUVdC
27
- QlF6UEp0cW1TZ2M1M2VETjdhU3pEUXdyOVRBTERDQmtnWURWUjBqQklHS01J
28
- R0gKZ0JRelBKdHFtU2djNTNlRE43YVN6RFF3cjlUQUxLRmtwR0l3WURFTE1B
29
- a0dBMVVFQmhNQ1ZWTXhFekFSQmdOVgpCQWdUQ2tOaGJHbG1iM0p1YVdFeEZq
30
- QVVCZ05WQkFjVERWTmhiaUJHY21GdVkybHpZMjh4RHpBTkJnTlZCQW9UCkJs
31
- TnBlRUZ5YlRFVE1CRUdBMVVFQXhNS2MybDRZWEp0TG1OdmJZSUpBS1B3RUVU
32
- VTViSG9NQXdHQTFVZEV3UUYKTUFNQkFmOHdEUVlKS29aSWh2Y05BUUVGQlFB
33
- RGdZRUFvb0VleFAvb1BhbTFUUDcxU3l1aHhNYit1VHJaYlNRZQpqVkIrRXhS
34
- d1dhZEd3YU5QVUE1NmQzOXF3YXZ3UCtpdSszSnBlb25OTVZ2YldYRjVuYUNY
35
- L2RORkllUkVIekVSClpEUlFZTXFydTlURU1uYTZIRDl6cGNzdEY3dndUaEdv
36
- dmxPUSszWTZwbFE0bk16aXBYY1o5VEhxczY1UElMMHEKZWFid3BDYkFvcG89
37
- Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
38
- date: 2012-09-02 00:00:00.000000000 Z
39
- dependencies: []
40
- description:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIGCTCCA/GgAwIBAgIJAK3igyLv2hNNMA0GCSqGSIb3D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ufGuTVLWF9FUUdMNK+TMbghnifT8/1
45
+ n+ES/gQPOnvmVkLDGw==
46
+ -----END CERTIFICATE-----
47
+ date: 2015-07-19 00:00:00.000000000 Z
48
+ dependencies:
49
+ - !ruby/object:Gem::Dependency
50
+ name: minitest
51
+ requirement: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 5.7.0
56
+ - - "<"
57
+ - !ruby/object:Gem::Version
58
+ version: '6'
59
+ type: :development
60
+ prerelease: false
61
+ version_requirements: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 5.7.0
66
+ - - "<"
67
+ - !ruby/object:Gem::Version
68
+ version: '6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">"
74
+ - !ruby/object:Gem::Version
75
+ version: 10.4.2
76
+ - - "<"
77
+ - !ruby/object:Gem::Version
78
+ version: '11'
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">"
84
+ - !ruby/object:Gem::Version
85
+ version: 10.4.2
86
+ - - "<"
87
+ - !ruby/object:Gem::Version
88
+ version: '11'
89
+ - !ruby/object:Gem::Dependency
90
+ name: simplecov
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 0.10.0
96
+ - - "<"
97
+ - !ruby/object:Gem::Version
98
+ version: '2'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: 0.10.0
106
+ - - "<"
107
+ - !ruby/object:Gem::Version
108
+ version: '2'
109
+ - !ruby/object:Gem::Dependency
110
+ name: coveralls
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: 0.8.2
116
+ - - "<"
117
+ - !ruby/object:Gem::Version
118
+ version: '2'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: 0.8.2
126
+ - - "<"
127
+ - !ruby/object:Gem::Version
128
+ version: '2'
129
+ description: 'Numeric #round, #floor, #ceil, #truncate methods'
41
130
  email: sixarm@sixarm.com
42
131
  executables: []
43
132
  extensions: []
44
133
  extra_rdoc_files: []
45
134
  files:
46
- - .gemtest
47
135
  - Rakefile
48
- - README.md
49
- - VERSION
50
136
  - lib/sixarm_ruby_numeric_round.rb
137
+ - lib/sixarm_ruby_numeric_round/float.rb
138
+ - lib/sixarm_ruby_numeric_round/numeric.rb
51
139
  - test/sixarm_ruby_numeric_round_test.rb
140
+ - test/sixarm_ruby_numeric_round_test/float_test.rb
141
+ - test/sixarm_ruby_numeric_round_test/numeric_test.rb
52
142
  homepage: http://sixarm.com/
53
- licenses: []
143
+ licenses:
144
+ - BSD
145
+ - GPL
146
+ - MIT
147
+ - PAL
148
+ - Various
149
+ metadata: {}
54
150
  post_install_message:
55
151
  rdoc_options: []
56
152
  require_paths:
57
153
  - lib
58
154
  required_ruby_version: !ruby/object:Gem::Requirement
59
- none: false
60
155
  requirements:
61
- - - ! '>='
156
+ - - ">="
62
157
  - !ruby/object:Gem::Version
63
158
  version: '0'
64
159
  required_rubygems_version: !ruby/object:Gem::Requirement
65
- none: false
66
160
  requirements:
67
- - - ! '>='
161
+ - - ">="
68
162
  - !ruby/object:Gem::Version
69
163
  version: '0'
70
164
  requirements: []
71
165
  rubyforge_project:
72
- rubygems_version: 1.8.23
166
+ rubygems_version: 2.4.8
73
167
  signing_key:
74
- specification_version: 3
75
- summary: SixArm.com » Ruby » Numeric round, floor, ceil, truncate methods
168
+ specification_version: 4
169
+ summary: SixArm.com » Ruby » Numeric round methods
76
170
  test_files:
77
171
  - test/sixarm_ruby_numeric_round_test.rb
172
+ - test/sixarm_ruby_numeric_round_test/float_test.rb
173
+ - test/sixarm_ruby_numeric_round_test/numeric_test.rb
78
174
  has_rdoc: true
metadata.gz.sig CHANGED
Binary file
data/.gemtest DELETED
File without changes
data/README.md DELETED
@@ -1,108 +0,0 @@
1
- # SixArm.com » Ruby » <br> Numeric #round, #floor, #ceil methods with precision
2
-
3
- * Doc: <http://sixarm.com/sixarm_ruby_numeric_round/doc>
4
- * Gem: <http://rubygems.org/gems/sixarm_ruby_numeric_round>
5
- * Repo: <http://github.com/sixarm/sixarm_ruby_numeric_round>
6
- * Email: Joel Parker Henderson, <joel@sixarm.com>
7
-
8
-
9
- ## Introduction
10
-
11
- Simple numeric rounding methods like #round, #floor, #ceil with various precisions.
12
-
13
- For docs go to <http://sixarm.com/sixarm_ruby_numeric_round/doc>
14
-
15
- Want to help? We're happy to get pull requests.
16
-
17
-
18
- ## Install quickstart
19
-
20
- Install:
21
-
22
- gem install sixarm_ruby_numeric_round
23
-
24
- Bundler:
25
-
26
- gem "sixarm_ruby_numeric_round", "~>1.0.0"
27
-
28
- Require:
29
-
30
- require "sixarm_ruby_numeric_round"
31
-
32
-
33
- ## Install with security (optional)
34
-
35
- To enable high security for all our gems:
36
-
37
- wget http://sixarm.com/sixarm.pem
38
- gem cert --add sixarm.pem
39
- gem sources --add http://sixarm.com
40
-
41
- To install with high security:
42
-
43
- gem install sixarm_ruby_numeric_round --test --trust-policy HighSecurity
44
-
45
-
46
- ## Examples
47
-
48
- Round at a given decimal point:
49
-
50
- 4.555.ceil_at(1) #=> 4.6
51
- 4.555.floor_at(1) #=> 4.5
52
- 4.555.round_at(1) #=> 4.6
53
- 4.555.truncate_at(1) #=> 4.5
54
-
55
- Round to a given precision:
56
-
57
- 4.555.ceil_to(0.1) #=> 4.6
58
- 4.555.floor_to(0.1) #=> 4.5
59
- 4.555.round_to(0.1) #=> 4.6
60
- 4.555.truncate_to(0.1) #=> 4.5
61
-
62
- Conceptually, the methods for round, floor, ceil, and truncate will typically be for floating point numbers.
63
- However, these methods can actually be for pretty much any Numeric object.
64
- For example, one could round an Integer to the nearest kilo.
65
-
66
-
67
- ## Credit
68
-
69
- These methods are based on the Facets library for Ruby and the developer named Trans.
70
-
71
- The #round_at and #round_to methods are exact copies and fully compatible with Facets. The rest of the methods are very similar code and fully co-existant with Facets.
72
-
73
- We're asking the Facets team to consider including the rest of the methods.
74
-
75
-
76
- ## Changes
77
-
78
- * 2012-09-01 1.0.2 Add #truncate_at and #truncate_to; improve floating division.
79
- * 2012-05-30 1.0.0 Create baesd on Facets methods by Trans.
80
-
81
-
82
- ## License
83
-
84
- You may choose any of these open source licenses:
85
-
86
- * Apache License
87
- * BSD License
88
- * CreativeCommons License, Non-commercial Share Alike
89
- * GNU General Public License Version 2 (GPL 2)
90
- * GNU Lesser General Public License (LGPL)
91
- * MIT License
92
- * Perl Artistic License
93
- * Ruby License
94
-
95
- The software is provided "as is", without warranty of any kind,
96
- express or implied, including but not limited to the warranties of
97
- merchantability, fitness for a particular purpose and noninfringement.
98
-
99
- In no event shall the authors or copyright holders be liable for any
100
- claim, damages or other liability, whether in an action of contract,
101
- tort or otherwise, arising from, out of or in connection with the
102
- software or the use or other dealings in the software.
103
-
104
- This license is for the included software that is created by SixArm;
105
- some of the included software may have its own licenses, copyrights,
106
- authors, etc. and these do take precedence over the SixArm license.
107
-
108
- Copyright (c) 2005-2012 Joel Parker Henderson
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.0.1