summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-06-28 12:22:59 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2012-06-28 12:22:59 +0200
commitfff8054390a5faf56443f42a884ecd0d107e0cab (patch)
tree19390ef9180abae6b878bd8737e2931a3ba38dca /examples
parent2ad62fbf4cbe4d7173559a3d559c1923d54405ea (diff)
downloadedoors-ruby-fff8054390a5faf56443f42a884ecd0d107e0cab.zip
edoors-ruby-fff8054390a5faf56443f42a884ecd0d107e0cab.tar.gz
examples/links.rb: do not use block as filter
Diffstat (limited to 'examples')
-rw-r--r--examples/links.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/examples/links.rb b/examples/links.rb
index ae3293c..b21a2e4 100644
--- a/examples/links.rb
+++ b/examples/links.rb
@@ -37,15 +37,11 @@ end
#
class Filter < Edoors::Door
#
- def initialize n, p, &block
- super n, p
- @filter = block
- end
- #
def receive_p p
if p.action!=Edoors::ACT_ERROR
# apply the filter
- @filter.call p
+ p['old'] = (p['person']['age']>=18)
+ p['sex'] = p['person']['sex']
# will follow the conditional link.
# see Room#_send and Room#_try_links
send_p p
@@ -75,7 +71,9 @@ if $0 == __FILE__
dom0 = Edoors::Spin.new 'dom0'
#
FileReader.new 'input', dom0, './examples/data.json'
- Filter.new('age_filter', dom0) { |p| p['old'] = (p['person']['age']>=30); p['sex']=p['person']['sex'] }
+ # the filter to be applied to each particle
+ Filter.new 'age_filter', dom0
+ # different output doors
OutputDoor.new 'output_f', dom0, 'woman'
OutputDoor.new 'output_m', dom0, 'man'
OutputDoor.new 'output_child', dom0, 'child'