randomevent 0.1.0 → 0.1.1
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 +22 -5
- data/lib/randomevent/version.rb +1 -1
- data/randomevent.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa1759b914c351f474e5ff60648733701b71046b
|
4
|
+
data.tar.gz: 5fafa21adac7d4cbce80d7f3a4f08b796b7c851b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d504d115ad2c8867e68b0d562040c7fc68c764bf538d29bb9a4a61451dc10a1e3d9b2f5c5a2cfc473d3d91091c8522050dfa3e6fe916c0caa375527e87bcf777
|
7
|
+
data.tar.gz: 9152d634dd1c28284a3d60972ba38f179b928e883df451d6e1391ad767b227512d6acb081ff04d63c0b0bd2492ab41a6971dac94e5f6af0e492aae11b06ffae6
|
data/README.md
CHANGED
@@ -1,5 +1,26 @@
|
|
1
|
-
#
|
1
|
+
# RandomEvent
|
2
2
|
|
3
|
+
RandomEvent is a DSL that makes it easy to create a set of blocks such that a single one in the set will be executed, based off the probability assigned to each one.
|
4
|
+
|
5
|
+
Example:
|
6
|
+
|
7
|
+
# half of the time it will output hello, 25% of the time goodbye
|
8
|
+
# and 25 % of the time the default will be executed
|
9
|
+
RandomEvent.new do |r|
|
10
|
+
r.chance 0.50 do
|
11
|
+
puts 'hello'
|
12
|
+
end
|
13
|
+
|
14
|
+
r.chance 0.25 do
|
15
|
+
puts 'goodbye'
|
16
|
+
end
|
17
|
+
|
18
|
+
# this is optional, there is no need to have a default case
|
19
|
+
# if it is not requried
|
20
|
+
r.chance :else do
|
21
|
+
puts '-'
|
22
|
+
end
|
23
|
+
end
|
3
24
|
|
4
25
|
## Installation
|
5
26
|
|
@@ -17,10 +38,6 @@ Or install it yourself as:
|
|
17
38
|
|
18
39
|
$ gem install randomevent
|
19
40
|
|
20
|
-
## Usage
|
21
|
-
|
22
|
-
|
23
|
-
|
24
41
|
## Development
|
25
42
|
|
26
43
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/randomevent/version.rb
CHANGED
data/randomevent.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Nathan Reed"]
|
10
10
|
spec.email = ["reednj@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{A Gem to execute a block
|
12
|
+
spec.summary = %q{A Gem to conditionally execute a block based on a certain probability}
|
13
13
|
spec.homepage = "http://github.com/reednj/randomevent"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: randomevent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Reed
|
@@ -93,6 +93,6 @@ rubyforge_project:
|
|
93
93
|
rubygems_version: 2.4.5
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
|
-
summary: A Gem to execute a block
|
96
|
+
summary: A Gem to conditionally execute a block based on a certain probability
|
97
97
|
test_files:
|
98
98
|
- test/randomevent_test.rb
|