number_name_string 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +7 -7
- data/lib/number_name_string/version.rb +1 -1
- data/lib/number_name_string.rb +5 -5
- data/number_name_string.gemspec +2 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18389d8f60a893aae5cbc7bafcb6203bff2144d1
|
4
|
+
data.tar.gz: e3352b3fd2905adfb213e5153892997de7de0ae0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b76e1acd8070fe2756ae0287403ff4c66ad9d4e6346a7f4af8b37f7a7171f026a8b0a19671835449bda7c2994d440e1647de7d25f20f0ecd7d50661ecc6570a9
|
7
|
+
data.tar.gz: ba86416c7e94971515aefd578db46c611b19070ec6397da20dca1ce5ebfe8e1424a4142359d6a9de362886863194ac1319d5eefba744427b415052acd4251122
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# NumberNameString
|
2
2
|
|
3
|
-
Converts
|
3
|
+
Converts to and from numbers and names (ie: 16.to_name == 'sixteen', 'forty.to_i == 40).
|
4
|
+
|
5
|
+
Pure Ruby with no dependencies outside of the standard library.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -25,22 +27,21 @@ NumberNameString has a few interfaces, the simplest is using Module methods:
|
|
25
27
|
```ruby
|
26
28
|
NumberNameString[4032] # "four hundred thirtytwo"
|
27
29
|
NumberNameString['six thousand'] # 6000
|
28
|
-
NumberNameString << 1019 # "one thousand nineteen"
|
29
30
|
```
|
30
31
|
|
31
32
|
The Convert class can be instantiated and used directly:
|
32
33
|
|
33
34
|
```ruby
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
numname = NumberNameString::Convert.new
|
36
|
+
numname[2000099] # "two million ninetynine"
|
37
|
+
numname['sixtytwo'] # 62
|
37
38
|
```
|
38
39
|
|
39
40
|
Or, as a mixin directly on Fixnum and String classes:
|
40
41
|
|
41
42
|
```ruby
|
42
43
|
include NumberNameString
|
43
|
-
716.
|
44
|
+
716.to_name # "seven hundred sixteen"
|
44
45
|
"four thousand two".to_i # 4002
|
45
46
|
91346.to_comma # "91,346"
|
46
47
|
'five thousand'.to_comma # "5,000"
|
@@ -56,7 +57,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
56
57
|
|
57
58
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/number_name_string. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
58
59
|
|
59
|
-
|
60
60
|
## License
|
61
61
|
|
62
62
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/lib/number_name_string.rb
CHANGED
@@ -9,6 +9,10 @@ module NumberNameString
|
|
9
9
|
def to_comma
|
10
10
|
self.to_s.to_comma
|
11
11
|
end
|
12
|
+
|
13
|
+
def to_name
|
14
|
+
NumberNameString[self]
|
15
|
+
end
|
12
16
|
end
|
13
17
|
|
14
18
|
# Would be ideal if we could only add this functionality only if included
|
@@ -20,16 +24,12 @@ module NumberNameString
|
|
20
24
|
end
|
21
25
|
|
22
26
|
def to_i
|
27
|
+
# TODO: verify output may be a string and this is necessary
|
23
28
|
result = NumberNameString[self]
|
24
|
-
# TODO: verify output of above may be a string
|
25
29
|
result.is_a?(String) ? result.old_to_i : result
|
26
30
|
end
|
27
31
|
end
|
28
32
|
|
29
|
-
def self.<<(num)
|
30
|
-
self[num]
|
31
|
-
end
|
32
|
-
|
33
33
|
def self.[](num)
|
34
34
|
(instance ||= NumberNameString::Convert.new)[num]
|
35
35
|
end
|
data/number_name_string.gemspec
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'number_name_string/convert'
|
5
4
|
require 'number_name_string/version'
|
6
5
|
|
7
6
|
Gem::Specification.new do |spec|
|
@@ -10,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
10
9
|
spec.authors = ["Rob Zwissler"]
|
11
10
|
spec.email = ["rob@zwissler.org"]
|
12
11
|
|
13
|
-
spec.summary = %q{Converts to and from numbers and
|
14
|
-
spec.description = %q{
|
12
|
+
spec.summary = %q{Converts to and from numbers and names (ie: 16.to_name == 'sixteen')}
|
13
|
+
spec.description = %q{Converts to and from numbers and names (ie: 16.to_name == 'sixteen', 'forty'.to_i == 40). Pure Ruby with no dependencies outside of the standard library.}
|
15
14
|
spec.homepage = "https://github.com/robzr/number_name_string"
|
16
15
|
spec.license = "MIT"
|
17
16
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: number_name_string
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Zwissler
|
@@ -52,8 +52,8 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
description: '
|
56
|
-
|
55
|
+
description: 'Converts to and from numbers and names (ie: 16.to_name == ''sixteen'',
|
56
|
+
''forty''.to_i == 40). Pure Ruby with no dependencies outside of the standard library.'
|
57
57
|
email:
|
58
58
|
- rob@zwissler.org
|
59
59
|
executables: []
|
@@ -98,5 +98,5 @@ rubyforge_project:
|
|
98
98
|
rubygems_version: 2.5.1
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
|
-
summary: 'Converts to and from numbers and
|
101
|
+
summary: 'Converts to and from numbers and names (ie: 16.to_name == ''sixteen'')'
|
102
102
|
test_files: []
|