frequency-dsl 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.7
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{frequency-dsl}
8
- s.version = "0.0.5"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tiago Peczenyj"]
@@ -1,24 +1,52 @@
1
+ # Module Frequency
2
+ # A small dsl written in ruby to work with frequency events (never, sometimes, always..)
3
+ #
1
4
  module Frequency
2
5
  NORMALLY = 0.75
3
6
  SOMETIMES = 0.50
4
7
  RARELY = 0.25
5
8
 
9
+ # always do something
10
+ # example:
11
+ # always { puts "ok"}
6
12
  def always(cond={})
7
13
  yield if block_given?
8
14
  end
9
15
 
16
+ # normally (75%) do something,
17
+ # see sometimes method
18
+ # example:
19
+ # normally { puts "ok"}
10
20
  def normally(cond={})
11
21
  execute_with_probability(cond,NORMALLY ) { yield } if block_given?
12
22
  end
13
23
 
24
+ # sometimes (50%) do something
25
+ # example:
26
+ # sometimes do
27
+ # # some code
28
+ # end
29
+ # or adjusting the probability
30
+ # sometimes :with_probability => 0.12 do
31
+ # # some code
32
+ # end
33
+ # you can use "12%" instead 0.12
34
+ # sometimes(:with_probability => '13.6%') { ... }
14
35
  def sometimes(cond={})
15
36
  execute_with_probability(cond,SOMETIMES) { yield } if block_given?
16
37
  end
17
38
 
39
+ # rarely (25%) do something,
40
+ # see sometimes method
41
+ # example:
42
+ # rarely { puts "ok"}
18
43
  def rarely(cond={})
19
44
  execute_with_probability(cond,RARELY ) { yield } if block_given?
20
45
  end
21
46
 
47
+ # never do something
48
+ # example:
49
+ # never { puts "ok"}
22
50
  def never(cond={})
23
51
  nil
24
52
  end
@@ -72,6 +72,15 @@
72
72
 
73
73
  <div id="contextContent">
74
74
 
75
+ <div id="description">
76
+ <p>
77
+ Module <a href="Frequency.html">Frequency</a> A small dsl written in ruby
78
+ to work with frequency events (<a href="Frequency.html#M000005">never</a>,
79
+ <a href="Frequency.html#M000003">sometimes</a>, <a
80
+ href="Frequency.html#M000001">always</a>..)
81
+ </p>
82
+
83
+ </div>
75
84
 
76
85
 
77
86
  </div>
@@ -139,11 +148,17 @@
139
148
  </div>
140
149
 
141
150
  <div class="method-description">
151
+ <p>
152
+ <a href="Frequency.html#M000001">always</a> do something example:
153
+ </p>
154
+ <pre>
155
+ always { puts &quot;ok&quot;}
156
+ </pre>
142
157
  <p><a class="source-toggle" href="#"
143
158
  onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
144
159
  <div class="method-source-code" id="M000001-source">
145
160
  <pre>
146
- <span class="ruby-comment cmt"># File lib/frequency.rb, line 6</span>
161
+ <span class="ruby-comment cmt"># File lib/frequency.rb, line 12</span>
147
162
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">always</span>(<span class="ruby-identifier">cond</span>={})
148
163
  <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
149
164
  <span class="ruby-keyword kw">end</span>
@@ -162,11 +177,17 @@
162
177
  </div>
163
178
 
164
179
  <div class="method-description">
180
+ <p>
181
+ <a href="Frequency.html#M000005">never</a> do something example:
182
+ </p>
183
+ <pre>
184
+ never { puts &quot;ok&quot;}
185
+ </pre>
165
186
  <p><a class="source-toggle" href="#"
166
187
  onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
167
188
  <div class="method-source-code" id="M000005-source">
168
189
  <pre>
169
- <span class="ruby-comment cmt"># File lib/frequency.rb, line 22</span>
190
+ <span class="ruby-comment cmt"># File lib/frequency.rb, line 50</span>
170
191
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">never</span>(<span class="ruby-identifier">cond</span>={})
171
192
  <span class="ruby-keyword kw">nil</span>
172
193
  <span class="ruby-keyword kw">end</span>
@@ -185,11 +206,18 @@
185
206
  </div>
186
207
 
187
208
  <div class="method-description">
209
+ <p>
210
+ <a href="Frequency.html#M000002">normally</a> (75%) do something, see <a
211
+ href="Frequency.html#M000003">sometimes</a> method example:
212
+ </p>
213
+ <pre>
214
+ normally { puts &quot;ok&quot;}
215
+ </pre>
188
216
  <p><a class="source-toggle" href="#"
189
217
  onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
190
218
  <div class="method-source-code" id="M000002-source">
191
219
  <pre>
192
- <span class="ruby-comment cmt"># File lib/frequency.rb, line 10</span>
220
+ <span class="ruby-comment cmt"># File lib/frequency.rb, line 20</span>
193
221
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">normally</span>(<span class="ruby-identifier">cond</span>={})
194
222
  <span class="ruby-identifier">execute_with_probability</span>(<span class="ruby-identifier">cond</span>,<span class="ruby-constant">NORMALLY</span> ) { <span class="ruby-keyword kw">yield</span> } <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
195
223
  <span class="ruby-keyword kw">end</span>
@@ -208,11 +236,18 @@
208
236
  </div>
209
237
 
210
238
  <div class="method-description">
239
+ <p>
240
+ <a href="Frequency.html#M000004">rarely</a> (25%) do something, see <a
241
+ href="Frequency.html#M000003">sometimes</a> method example:
242
+ </p>
243
+ <pre>
244
+ rarely { puts &quot;ok&quot;}
245
+ </pre>
211
246
  <p><a class="source-toggle" href="#"
212
247
  onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
213
248
  <div class="method-source-code" id="M000004-source">
214
249
  <pre>
215
- <span class="ruby-comment cmt"># File lib/frequency.rb, line 18</span>
250
+ <span class="ruby-comment cmt"># File lib/frequency.rb, line 43</span>
216
251
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rarely</span>(<span class="ruby-identifier">cond</span>={})
217
252
  <span class="ruby-identifier">execute_with_probability</span>(<span class="ruby-identifier">cond</span>,<span class="ruby-constant">RARELY</span> ) { <span class="ruby-keyword kw">yield</span> } <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
218
253
  <span class="ruby-keyword kw">end</span>
@@ -231,11 +266,33 @@
231
266
  </div>
232
267
 
233
268
  <div class="method-description">
269
+ <p>
270
+ <a href="Frequency.html#M000003">sometimes</a> (50%) do something example:
271
+ </p>
272
+ <pre>
273
+ sometimes do
274
+ # some code
275
+ end
276
+ </pre>
277
+ <p>
278
+ or adjusting the probability
279
+ </p>
280
+ <pre>
281
+ sometimes :with_probability =&gt; 0.12 do
282
+ # some code
283
+ end
284
+ </pre>
285
+ <p>
286
+ you can use &quot;12%&quot; instead 0.12
287
+ </p>
288
+ <pre>
289
+ sometimes(:with_probability =&gt; '13.6%') { ... }
290
+ </pre>
234
291
  <p><a class="source-toggle" href="#"
235
292
  onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
236
293
  <div class="method-source-code" id="M000003-source">
237
294
  <pre>
238
- <span class="ruby-comment cmt"># File lib/frequency.rb, line 14</span>
295
+ <span class="ruby-comment cmt"># File lib/frequency.rb, line 35</span>
239
296
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sometimes</span>(<span class="ruby-identifier">cond</span>={})
240
297
  <span class="ruby-identifier">execute_with_probability</span>(<span class="ruby-identifier">cond</span>,<span class="ruby-constant">SOMETIMES</span>) { <span class="ruby-keyword kw">yield</span> } <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
241
298
  <span class="ruby-keyword kw">end</span>
@@ -1 +1 @@
1
- Wed, 19 May 2010 21:49:00 -0300
1
+ Wed, 19 May 2010 22:05:20 -0300
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Wed May 19 21:40:37 -0300 2010</td>
59
+ <td>Wed May 19 22:02:24 -0300 2010</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -68,6 +68,13 @@
68
68
 
69
69
  <div id="contextContent">
70
70
 
71
+ <div id="description">
72
+ <p>
73
+ Module <a href="../../classes/Frequency.html">Frequency</a> A small dsl
74
+ written in ruby to work with frequency events (never, sometimes, always..)
75
+ </p>
76
+
77
+ </div>
71
78
 
72
79
 
73
80
  </div>
@@ -5,13 +5,13 @@
5
5
 
6
6
  <!--
7
7
 
8
- frequency 0.0.4
8
+ frequency 0.0.6
9
9
 
10
10
 
11
11
  -->
12
12
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
13
  <head>
14
- <title>frequency 0.0.4
14
+ <title>frequency 0.0.6
15
15
  </title>
16
16
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
17
17
  </head>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frequency-dsl
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tiago Peczenyj