numerology 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/CHANGELOG +2 -0
- data/features/numerology.feature +8 -1
- data/features/step_definitions/numerology_steps.rb +1 -1
- data/lib/numerology.rb +11 -3
- data/lib/numerology/version.rb +1 -1
- metadata +3 -2
data/CHANGELOG
ADDED
data/features/numerology.feature
CHANGED
@@ -16,4 +16,11 @@ Feature: Formatting a number
|
|
16
16
|
| 123456 | 1.111 | 123.456 |
|
17
17
|
| 123456 | 1 111 | 123 456 |
|
18
18
|
| 1234567 | 1,111 | 1,234,567 |
|
19
|
-
| 1234567 | 1.111 | 1.234.567 |
|
19
|
+
| 1234567 | 1.111 | 1.234.567 |
|
20
|
+
| 1234 | 01111 | 01234 |
|
21
|
+
| 123 | 01111 | 00123 |
|
22
|
+
| 12 | 01111 | 00012 |
|
23
|
+
| 12345 | 01111 | 12345 |
|
24
|
+
| 12345 | 01,111 | 12,345 |
|
25
|
+
| 1234 | 01,111 | 01,234 |
|
26
|
+
| 123 | 01,111 | 00,123 |
|
data/lib/numerology.rb
CHANGED
@@ -2,11 +2,19 @@ require "numerology/version"
|
|
2
2
|
|
3
3
|
module Numerology
|
4
4
|
def format_like(example)
|
5
|
-
|
5
|
+
if example =~ /^[0\s]/
|
6
|
+
formatted_string = "%#{example[0]}#{example.gsub(/\D/,'').length}d" % self
|
7
|
+
else
|
8
|
+
formatted_string = self.to_s
|
9
|
+
end
|
10
|
+
|
11
|
+
formatted_string = separate_thousands(formatted_string, example[-4]) if example =~ /(\D)\d{3}$/
|
12
|
+
|
13
|
+
formatted_string
|
6
14
|
end
|
7
15
|
|
8
|
-
def separate_thousands(separator)
|
9
|
-
|
16
|
+
def separate_thousands(formatted_string, separator)
|
17
|
+
formatted_string =~ /([^\.]*)(\..*)?/
|
10
18
|
int, dec = $1.reverse, $2 ? $2 : ""
|
11
19
|
while int.gsub!(/(,|\.|^)(\d{3})(\d)/, '\1\2'+separator+'\3')
|
12
20
|
end
|
data/lib/numerology/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: numerology
|
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: 2013-02-
|
12
|
+
date: 2013-02-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -51,6 +51,7 @@ extensions: []
|
|
51
51
|
extra_rdoc_files: []
|
52
52
|
files:
|
53
53
|
- .gitignore
|
54
|
+
- CHANGELOG
|
54
55
|
- Gemfile
|
55
56
|
- LICENSE
|
56
57
|
- README.md
|