def_enum_helper 0.6.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/def_enum_helper/version.rb +1 -1
- data/lib/def_enum_helper.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6716d54dc234d894fe3c944da6eed2f95a333dcf
|
4
|
+
data.tar.gz: 97e542fc0a6594f65720686fd52f7a2ed9edc4c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb0afcc78f37940a3c925177533b80b57f28499092bd0e3c2e2d75c13694f1454f2aab7be55bde68c002d6dabc80f60dab831b44eb071603567ecb0f624dc62f
|
7
|
+
data.tar.gz: da0bdcf1505507f3c5b62e3ad728c6308a647897ad4cc364baafe86034ee1087b27abfd7d37034b6fb059ab6e14b0fa5ec90d68f1af14a3781281dc63465057c
|
data/README.md
CHANGED
@@ -35,6 +35,7 @@ YinYang["阳"] # same as YinYang[1]
|
|
35
35
|
YinYang.all # 所有枚举的struct array [#<struct index=1, display="阳">, # <struct index=2, display="阴">]
|
36
36
|
puts YinYang.count # 2
|
37
37
|
YinYang.each{|x| puts x} # <struct index=1, display="阳"> #<struct index=2, display="阴">
|
38
|
+
YinYang.map{|x| x} # [#<struct index=1, display="阳">, #<struct index=2, display="阴">]
|
38
39
|
puts YinYang.to_hash_array # [{:index=>1, :display=>"阳"}, {:index=>2, :display=>"阴"}]
|
39
40
|
puts YingYang.to_json_array # [{"index":1,"display":"阳"},{"index":2,"display":"阴"}]
|
40
41
|
```
|
data/lib/def_enum_helper.rb
CHANGED
@@ -16,6 +16,7 @@ require "def_enum_helper/version"
|
|
16
16
|
# YinYang.all # 所有枚举的struct array [#<struct index=1, display="阳">, # <struct index=2, display="阴">]
|
17
17
|
# puts YinYang.count # 2
|
18
18
|
# YinYang.each{|x| puts x} # <struct index=1, display="阳"> #<struct index=2, display="阴">
|
19
|
+
# YinYang.map{|x| x} # [#<struct index=1, display="阳">, #<struct index=2, display="阴">]
|
19
20
|
# puts YinYang.to_hash_array # [{:index=>1, :display=>"阳"}, {:index=>2, :display=>"阴"}]
|
20
21
|
# puts YingYang.to_json_array # [{"index":1,"display":"阳"},{"index":2,"display":"阴"}]
|
21
22
|
|
@@ -78,6 +79,7 @@ def define_iterator_methods(m, enum_index_hash)
|
|
78
79
|
m.define_singleton_method(:map) { |&blk| enum_index_hash.values.map { |v| blk.call(v) } }
|
79
80
|
|
80
81
|
m.define_singleton_method(:all) { enum_index_hash.values }
|
82
|
+
m.define_singleton_method(:keys) { enum_index_hash.keys }
|
81
83
|
end
|
82
84
|
|
83
85
|
def define_subscript_method(m, enum_index_hash, enum_display_hash)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: def_enum_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Zhang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
version: '0'
|
74
74
|
requirements: []
|
75
75
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.6.
|
76
|
+
rubygems_version: 2.6.13
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: define very powerful enum class
|