def_enum_helper 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 590ddea64979d3f00a57ed5bf26f468377ca13c7
4
- data.tar.gz: a362fd79ea34dbe0f1e0ff72190637acf44a7988
3
+ metadata.gz: f228f2de771b59063b78d5cc48b4cd09d90fedd0
4
+ data.tar.gz: 9acd36ca28215033c92183105c6bf3f51d6a1bb3
5
5
  SHA512:
6
- metadata.gz: b9c5c97a0201046f5bcb2e08eff89a21dc2ad9fd202d3e46cfa3d234497ca3e24fc88ab0135dba49db08fb3a8f14856c40263f2d404fb3bb6c2ab0a8bd14202d
7
- data.tar.gz: 04aeb46bad251b7ef006b1fd1ac9b5ca5501110e8c6dc0b93d24e24cc7f8767008322aa50c1112d167164850884c3c62423ab5a70aa6435fef3e0fe214a94581
6
+ metadata.gz: 8c84b07d8820b4956e3a01f67073ca35ddf2f46031a0b5ec87d348f4fcb1e4ad45b2c9a95e39a2576d80de37f991dc818219aa94fb45fdaf459ee5713fee151c
7
+ data.tar.gz: 0b1273f73956933aa6a4476cd8f69c3ca44ae4ff17f163d14c7219aabe86a96961ba8244b55bbd84132cbe9cea78499559bdfb4696532277531f2ffe8f87dc4c
@@ -1,20 +1,43 @@
1
1
  require "def_enum_helper/version"
2
2
 
3
- # example
3
+ # Usage
4
+
5
+ # # 默认枚举从1开始递增
4
6
 
5
7
  # def_enum :YinYang, {YANG: "阳", YIN: "阴"}
6
8
 
7
- # puts YinYang::YANG #1
8
- # puts YinYang::YIN #2
9
+ # puts YinYang::YANG # 1
10
+ # puts YinYang::YIN # 2
9
11
  # y = YinYang[1]
10
- # puts y.index #1
11
- # puts y.display #阳
12
- # puts YinYang[:YANG] #same as YinYang[1]
13
- # puts YinYang["阳"] #same as YinYang[1]
14
- # YinYang.all #所有枚举的struct array [#<struct index=1, display="阳">, #<struct index=2, display="阴">]
15
- # puts YinYang.count #2
16
- # YinYang.each{|x| puts x} #<struct index=1, display="阳"> #<struct index=2, display="阴">
17
- # puts YingYang.to_json_array #[{"index":1,"display":"阳"},{"index":2,"display":"阴"}]
12
+ # puts y.index # 1
13
+ # puts y.display # 阳
14
+ # YinYang[:YANG] # same as YinYang[1]
15
+ # YinYang["阳"] # same as YinYang[1]
16
+ # YinYang.all # 所有枚举的struct array [#<struct index=1, display="阳">, # <struct index=2, display="阴">]
17
+ # puts YinYang.count # 2
18
+ # YinYang.each{|x| puts x} # <struct index=1, display="阳"> #<struct index=2, display="阴">
19
+ # puts YinYang.to_hash_array # [{:index=>1, :display=>"阳"}, {:index=>2, :display=>"阴"}]
20
+ # puts YingYang.to_json_array # [{"index":1,"display":"阳"},{"index":2,"display":"阴"}]
21
+
22
+ # # 自定义枚举整数值
23
+
24
+ # def_enum_with_index(:DataOperationType,
25
+ # [:INSERT, 3, '插入'],
26
+ # [:UPDATE, 4, '修改'],
27
+ # [:DELETE, 5, '删除'])
28
+
29
+ # puts DataOperationType::INSERT # 3
30
+
31
+ # # 自定义枚举对象
32
+ # CustomStruct = Struct.new(:index, :display, :short_name)
33
+
34
+ # def_enum_struct_with_index(:Country,
35
+ # {
36
+ # CHINA: CustomStruct.new(1, '中华人民共和国', '中国'),
37
+ # USA: CustomStruct.new(2, '美利坚合众国', '美国')
38
+ # })
39
+
40
+ # Country[:CHINA] # <struct CustomStruct index=1, display="中华人民共和国", short_name="中国">
18
41
 
19
42
  DEFAULT_ENUM_BASE_INDEX = 1
20
43
 
@@ -1,3 +1,3 @@
1
1
  module DefEnumHelper
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.0
4
+ version: 0.2.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: 2016-11-23 00:00:00.000000000 Z
11
+ date: 2016-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler