enums 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +56 -2
  3. data/lib/enums/version.rb +2 -2
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca648558b0ebcd1b42f7f6d587ef888c7f7f58aa
4
- data.tar.gz: fa6ce8d8931379a42491296016e498ec769c4194
3
+ metadata.gz: 0f703a80394cb87387c0efe3311aed2c59220710
4
+ data.tar.gz: 39b065497a6e1fb107de0819e62999fc14c14fe0
5
5
  SHA512:
6
- metadata.gz: fdbc9303c337e5196444164cef1268a05f70252acc47163d2002c22b807dae50bb088b02e0b56f975753f5442492506a2fb37f555a49ff36b3011db1900b927a
7
- data.tar.gz: 759a5706d1621c805fbfa985591cd1fbe3b832a2be191555ea1c9b44850548c906abd8b1cb8f5e01abbedecced1b3335a23a5eaf8f5b28edaed2665ce602725d
6
+ metadata.gz: 419c10d70475ab3b6800b6895dcb7eb2422f28c4284a27811c3ec0339922268c953e0a0844bb874a4554c5193f6d5b1b4e328cca9a129e82e694be73f6b69427
7
+ data.tar.gz: 3379a2c0395e83430e10b862f0de84cf5f4cc1fc2aebe5cbe5fd28e1e2eaf74c5a98a3b25b285cfdccc49841d69ad00d294e6f8d83c2c55fcc50595f6ab0e00b
data/README.md CHANGED
@@ -6,7 +6,6 @@ enums library / gem - safe enumeration types - a set of symbolic keys bound to u
6
6
  * bugs :: [github.com/s6ruby/enums/issues](https://github.com/s6ruby/enums/issues)
7
7
  * gem :: [rubygems.org/gems/enums](https://rubygems.org/gems/enums)
8
8
  * rdoc :: [rubydoc.info/gems/enums](http://rubydoc.info/gems/enums)
9
- * forum :: [wwwmake](http://groups.google.com/group/wwwmake)
10
9
 
11
10
 
12
11
  ## Why `enums` in Ruby?
@@ -48,7 +47,7 @@ Why? Why not? Discuss.
48
47
  Enum.new( 'Color', :red, :green, :blue )
49
48
  ```
50
49
 
51
- (auto-)builds a class and code like:
50
+ (Auto-)builds a class and code like:
52
51
 
53
52
  ``` ruby
54
53
  class Enum
@@ -122,6 +121,61 @@ color.is_a? Color #=> true
122
121
  ...
123
122
  ```
124
123
 
124
+ Let's try another example:
125
+
126
+ ``` ruby
127
+ Enum.new( 'State', :fundraising, :expired_refund, :successful )
128
+
129
+ State.values #=> [0, 1, 2]
130
+ State.keys #=> [:fundraising, :expired_refund, :successful]
131
+
132
+ State.members #=> [FUNDRAISING, EXPIRED_REFUND, SUCCESSFUL]
133
+ # -or-
134
+ # [<State @key=:fundraising, @value=0>,
135
+ # <Safe @key=:expired_refund, @value=1>,
136
+ # <State @key=:successful, @value=2>]
137
+ State.members[0].key #=> :fundraising
138
+ State.members[0].value #=> 0
139
+ State.members[1].key #=> :expired_refund
140
+ State.members[1].value #=> 1
141
+
142
+ State.fundraising.value #=> 0
143
+ State.fundraising.key #=> :fundraising
144
+ State::FUNDRAISING.value #=> 0
145
+ State::FUNDRAISING.key #=> :fundraising
146
+
147
+ state = State.fundraising
148
+ state.fundraising? #=> true
149
+ state.value #=> 0
150
+
151
+ State(0) #=> State::FUNDRAISING
152
+ State(1) #=> State::EXPIRED_REFUND
153
+ State(2) #=> State::SUCCESSFUL
154
+
155
+ State.zero # same as State(0)
156
+ State(0) == State.zero #=> true
157
+ State(1) == State.zero #=> false
158
+
159
+ State.value(0) #=> State::FUNDRAISING
160
+ State[:fundraising] #=> State::FUNDRAISING
161
+ State.key(:fundraising) # same as State[:fundraising]
162
+ # ...
163
+ ```
164
+
165
+ and so on.
166
+
167
+
168
+
169
+ ## More "Real World" Enum Samples
170
+
171
+ - [The "Red Paper" about sruby](https://github.com/s6ruby/redpaper) - Small, Smart, Secure, Safe, Solid & Sound (S6) Ruby - The Ruby Programming Language for Contract / Transaction Scripts on the Blockchain World Computer - Yes, It's Just Ruby
172
+ - [Ruby Sample Contracts for the Universum Blockchain/World Computer Runtime](https://github.com/s6ruby/universum-contracts)
173
+
174
+
175
+ ## More Safe Data Structure (Array, Hash, Struct)
176
+
177
+ [Safe Data Structures (Array, Hash, Struct)](https://github.com/s6ruby/safestruct) - Say goodbye to null / nil (and maybe) and the Billion-Dollar mistake. Say hello to zero and the Billon-Dollar fix.
178
+
125
179
 
126
180
 
127
181
  ## License
@@ -3,9 +3,9 @@
3
3
  ## note: use a (new) class Enums (with s!! at the end) for version info
4
4
  class Enums
5
5
 
6
- MAJOR = 0
6
+ MAJOR = 1
7
7
  MINOR = 0
8
- PATCH = 1
8
+ PATCH = 0
9
9
  VERSION = [MAJOR,MINOR,PATCH].join('.')
10
10
 
11
11
  def self.version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enums
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer