processi

about processes and engines

decision, accumulation

I had a few email exchanges with Fu and I ended up integrating Ruby ranges and ‘accumulate‘ into OpenWFEru’s Ruby CSV decision tables (see that post for an introduction to them).

Not much explanations, just code and links. A Ruby range (x..y) is used in the CSV table to express an age range and ‘accumulate’ is used in the second version of the CSV table to gather a list of results instead of one single result.

The two examples are runnable with the OpenWFEru trunk (will be part of the 0.9.16 gem, promised), so there is some manual work :

wget -O dec.rb http://pastie.caboo.se/pastes/106162/download
svn checkout http://openwferu.rubyforge.org/svn/trunk/openwfe-ruby/lib owfelib
ruby -Iowfelib dec.rb

Here’s what the code looks like, it’s about determining which sales person is appropriate for a given customer :



Noticed that only one answer came back per customer profile ?

If you add the “accumulate” key word on top of the CSV table, you’ll end up with

thorsten, ojiisan
adeslky, bronco, kerfelden
adeslky, swanson
adeslky, bronco, korolev
espadas, ojiisan, korolev

instead of

thorsten
adeslky
adeslky
adeslky
espadas

which were just plain ‘first matches’.

The rdoc of CsvTable is available as well as an [incomplete] page about decision implementations.

Written by John Mettraux

October 12, 2007 at 12:22 am

Posted in decision, ruby

%d bloggers like this: