ruby-nuggets 0.1.0.210 → 0.1.1.214
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/lib/nuggets/numeric/signum.rb +48 -0
- data/lib/nuggets/version.rb +1 -1
- metadata +3 -2
data/README
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
#--
|
2
|
+
###############################################################################
|
3
|
+
# #
|
4
|
+
# A component of ruby-nuggets, some extensions to the Ruby programming #
|
5
|
+
# language. #
|
6
|
+
# #
|
7
|
+
# Copyright (C) 2007-2008 Jens Wille #
|
8
|
+
# #
|
9
|
+
# Authors: #
|
10
|
+
# Jens Wille <jens.wille@uni-koeln.de> #
|
11
|
+
# #
|
12
|
+
# ruby-nuggets is free software; you can redistribute it and/or modify it #
|
13
|
+
# under the terms of the GNU General Public License as published by the Free #
|
14
|
+
# Software Foundation; either version 3 of the License, or (at your option) #
|
15
|
+
# any later version. #
|
16
|
+
# #
|
17
|
+
# ruby-nuggets is distributed in the hope that it will be useful, but WITHOUT #
|
18
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
20
|
+
# more details. #
|
21
|
+
# #
|
22
|
+
# You should have received a copy of the GNU General Public License along #
|
23
|
+
# with ruby-nuggets. If not, see <http://www.gnu.org/licenses/>. #
|
24
|
+
# #
|
25
|
+
###############################################################################
|
26
|
+
#++
|
27
|
+
|
28
|
+
class Numeric
|
29
|
+
|
30
|
+
# call-seq:
|
31
|
+
# num.signum => -1, 0, 1
|
32
|
+
#
|
33
|
+
#
|
34
|
+
def signum
|
35
|
+
self > 0 ? 1 : self < 0 ? -1 : 0
|
36
|
+
end
|
37
|
+
|
38
|
+
alias_method :sign, :signum
|
39
|
+
alias_method :sgn, :signum
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
if $0 == __FILE__
|
44
|
+
[123, -123, 0, 0.001, 1.23, -12.3].each { |n|
|
45
|
+
p n
|
46
|
+
p n.sgn
|
47
|
+
}
|
48
|
+
end
|
data/lib/nuggets/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-nuggets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1.214
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Wille
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-02-
|
12
|
+
date: 2008-02-21 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -47,6 +47,7 @@ files:
|
|
47
47
|
- lib/nuggets/array/monotone.rb
|
48
48
|
- lib/nuggets/array/format.rb
|
49
49
|
- lib/nuggets/array/combination.rb
|
50
|
+
- lib/nuggets/numeric/signum.rb
|
50
51
|
- lib/nuggets/util/content_type.rb
|
51
52
|
- lib/nuggets/util/i18n.rb
|
52
53
|
- lib/nuggets/file/which.rb
|