From fff8054390a5faf56443f42a884ecd0d107e0cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 28 Jun 2012 12:22:59 +0200 Subject: examples/links.rb: do not use block as filter --- examples/links.rb | 12 +++++------- 1 file 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' -- cgit v1.1-2-g2b99