rubenum 1.0.1 → 1.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.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/rubenum.rb +6 -6
- data/rubenum.gemspec +2 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40dfdc334f527dd44f5199e9160e8c62d0c13304e0d54f1e2203e0909b628eaf
|
4
|
+
data.tar.gz: e841cb03f57411073b5598d1d813bb2d22e22014eef1cb238f0d8bdb9bac67eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 505fad695cd0b7e33b5b9aa625fce6db83d3d7308e38e0a3fd771277bd78729f2fca8cdf278dbe37fa740deda3a2bfe594ce55ad05160faf1d093e7268d867fe
|
7
|
+
data.tar.gz: 7c7bc6d24d815c6da8d48c0c88f5a782b74c75d0c79ce7b327cc2e65ff2e9e0b03fffeaee67edbde2e1566fe199bf0bd6260b5408ab8ecf27dbfb01444831011
|
data/README.md
CHANGED
@@ -8,16 +8,16 @@ You can install the Rubenum gem via `gem install rubenum`.
|
|
8
8
|
|
9
9
|
## Usage
|
10
10
|
|
11
|
-
Create
|
11
|
+
Create a new enumeration from an array of strings with `Rubenum.new`.
|
12
12
|
Only valid Ruby identifiers are accepted.
|
13
13
|
By default, every element will be capitalized in order to make valid Ruby constant identifiers.
|
14
14
|
|
15
15
|
### Arguments
|
16
16
|
- elements (array of string) : array containing the elements of the enumeration
|
17
|
-
- upcase (optional boolean (default:false)) : true => upcase elements' name instead of capitalizing them
|
17
|
+
- upcase (optional boolean (default:false)) : true => upcase the elements' name instead of capitalizing them
|
18
18
|
- binary_values (optional boolean (default:false)) : true => use binary values (1 2 4 8 16 ...) instead of incremental values (1 2 3 4 5 ...)
|
19
19
|
|
20
20
|
### Example
|
21
|
-
|
22
|
-
puts
|
21
|
+
colors = Rubenum.new(%w[red orange green])
|
22
|
+
puts colors::Orange # => 2
|
23
23
|
|
data/lib/rubenum.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# Rubenum allows you to create simple enumerations in Ruby.
|
2
2
|
module Rubenum
|
3
|
-
# Create
|
3
|
+
# Create a new enumeration from an array of strings with `Rubenum.new`.
|
4
4
|
# Only valid Ruby identifiers are accepted.
|
5
5
|
# By default, every element will be capitalized in order to make valid Ruby constant identifiers.
|
6
6
|
#
|
7
7
|
# Arguments :
|
8
8
|
# - elements (array of string) : array containing the elements of the enumeration
|
9
|
-
# - upcase (optional boolean (default:false)) : true => upcase elements' name instead of capitalizing them
|
9
|
+
# - upcase (optional boolean (default:false)) : true => upcase the elements' name instead of capitalizing them
|
10
10
|
# - binary_values (optional boolean (default:false)) : true => use binary values (1 2 4 8 16 ...) instead of incremental values (1 2 3 4 5 ...)
|
11
11
|
#
|
12
12
|
# Example :
|
13
|
-
#
|
14
|
-
# puts
|
13
|
+
# colors = Rubenum.new(%w[red orange green])
|
14
|
+
# puts colors::Orange # => 2
|
15
15
|
def self.new(elements, upcase: false, binary_values: false)
|
16
16
|
Module.new do |mod|
|
17
17
|
raise ArgumentError, "<elements> must be an array" unless elements.is_a?(Array)
|
@@ -33,11 +33,11 @@ module Rubenum
|
|
33
33
|
value += i
|
34
34
|
end
|
35
35
|
|
36
|
-
# Add the element to the
|
36
|
+
# Add the element to the enumeration
|
37
37
|
mod.const_set(e, value)
|
38
38
|
end
|
39
39
|
|
40
|
-
# Freeze the
|
40
|
+
# Freeze the module so it can't be modifed
|
41
41
|
mod.freeze
|
42
42
|
end
|
43
43
|
end
|
data/rubenum.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'rubenum'
|
3
|
-
s.version = '1.0.
|
4
|
-
s.summary = "
|
3
|
+
s.version = '1.0.2'
|
4
|
+
s.summary = "Create simple enumerations in Ruby."
|
5
5
|
s.author = 'Jérémy Blain'
|
6
6
|
s.files = Dir['lib/**/*'] + Dir['test/**/*']
|
7
7
|
s.files += ['LICENSE', 'README.md', 'Rakefile', 'rubenum.gemspec']
|
@@ -10,7 +10,6 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = 'http://github.com/blainjeremy/rubenum'
|
11
11
|
s.email = 'blain.jeremy@gmail.com'
|
12
12
|
|
13
|
-
s.date = '2019-05-06'
|
14
13
|
s.extra_rdoc_files = ['README.md', 'LICENSE']
|
15
14
|
end
|
16
15
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubenum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jérémy Blain
|
@@ -46,5 +46,5 @@ requirements: []
|
|
46
46
|
rubygems_version: 3.0.3
|
47
47
|
signing_key:
|
48
48
|
specification_version: 4
|
49
|
-
summary:
|
49
|
+
summary: Create simple enumerations in Ruby.
|
50
50
|
test_files: []
|