numfix 0.0.1 → 0.0.2
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/lib/numfix.rb +13 -13
- metadata +2 -2
data/lib/numfix.rb
CHANGED
@@ -1,4 +1,16 @@
|
|
1
|
+
# The main Numfix class
|
1
2
|
class Numfix
|
3
|
+
|
4
|
+
# Examples:
|
5
|
+
# >> Numfix.fix(1)
|
6
|
+
# => 1st
|
7
|
+
#
|
8
|
+
# >> Numfix.fix(334)
|
9
|
+
# => 334th
|
10
|
+
#
|
11
|
+
# @param [Integer] number to be suffixed
|
12
|
+
# @return [String] number with suffix attached
|
13
|
+
|
2
14
|
def self.fix(number)
|
3
15
|
last = number.to_s[-1,1]
|
4
16
|
if last == "1"
|
@@ -7,19 +19,7 @@ class Numfix
|
|
7
19
|
puts number.to_s + "nd"
|
8
20
|
elsif last == "3"
|
9
21
|
puts number.to_s + "rd"
|
10
|
-
elsif last == "4"
|
11
|
-
puts number.to_s + "th"
|
12
|
-
elsif last == "5"
|
13
|
-
puts number.to_s + "th"
|
14
|
-
elsif last == "6"
|
15
|
-
puts number.to_s + "th"
|
16
|
-
elsif last == "7"
|
17
|
-
puts number.to_s + "th"
|
18
|
-
elsif last == "8"
|
19
|
-
puts number.to_s + "th"
|
20
|
-
elsif last == "9"
|
21
|
-
puts number.to_s + "th"
|
22
|
-
elsif last == "0"
|
22
|
+
elsif last == "4" || last == "5" || last == "6" || last == "7" || last == "8" || last == "9" || last == "0"
|
23
23
|
puts number.to_s + "th"
|
24
24
|
else
|
25
25
|
puts number.to_s
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: numfix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-30 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: An easy way to suffix your numbers
|
15
15
|
email: elysedougherty@gmail.com
|