about processes and engines

ruby decision tables

update (2008/01/28) : I’ve packaged this ruby decision table system into its own “rufus-decision” gem.

It’s part of OpenWFEru 0.9.4 that will be released this week.

I’ve already blogged about decision tables. Now the implementation is available in Ruby as well.

Disclaimer : this decision table implementation, whether in Java or Ruby is not meant to replace a full rules system with features like forward and backward chaining, RETE implementations and the like. But it covers a lot of cases. Be pragmatic.

For example, in our workflow definition, there’s a point where we’ve got to decide if we should take our umbrella when going to work (please no comments).
In pseudo-code, take would look like :

    if weather == "rainy"
        take_umbrella = "yes"
    elsif weather == "cloudy"
        take_umbrella = "maybe"
        take_umbrella = "no"

spreadsheetAs we don’t want to clutter our process definition with such cruft (or we simply don’t want to hardcode that into our source), we fire up our spreadsheet and write down the [business] rule.

That makes for a nice CSV file :

in:weather, in:month, out:take_umbrella?

Leveraging OpenWFEru CSV tables, we can write such Ruby code :

require 'openwfe/util/csvtable'

table ="path/to/our/file.csv")

h = { "weather" => "cloudy" }

puts h["table_umbrella?"]
    # will yield "no"

h = { "weather" => "cloudy", "month" => "june" }

puts h["table_umbrella?"]
    # will yield "yes"

# ...

That feature will be available with OpenWFEru 0.9.4 (or immediately by checking out OpenWFEru). You can already have a look at the unit tests for it.

The documentation for CSV tables as [decision] participants to business processes will be available soon.

Written by John Mettraux

February 11, 2007 at 9:25 am

Posted in openwfe, openwferu, ruby, rules

3 Responses

Subscribe to comments with RSS.

  1. Hi John.

    Your mailer-MTA can’t receive my mail again.
    there was a same case in the last december.
    My mailer seem unable to deliver my message to you.
    Whenever I send to you, mail are return back, and i am disappointment.

    Is it my env probrem, or yours?
    If my problem, I will have to resolve.

    I send mail to you today.




    February 13, 2007 at 9:10 am

  2. Hi
    I have an assignment to do and this is the what the problem saids to do: 3. Along with the course work percentage, Mr. Miko will use the attendance percentage in making a decision about the grade that the student should receive. Please make a decision table and decision tree to represent the following grading scheme that Mr. Miko will use. Students can receive the following grades from Mr. Miko: A, B, C, D, or F. When looking at course work, he uses the standard grading methodology: 90-100 A, 80-89 B, 70-79 C, 60-69 D, Below 60 F.. However he can also reduce a person’s grade as follows: those whose attendance is less than 75% will be reduced one letter grade, those whose attendance is less than 60% will reduced two letter grades, those who miss more than 50% of classes will fail regardless of their percentage grade in the course work. Additionally, Mr. Miko will refer any student who is an athlete that receives a grade lower than a “C” or whose attendance is less than 75% to the Director of Student Athlete Development.

    Craig Bowie

    March 21, 2007 at 4:29 pm

  3. Hi Craig,

    the users mailing list for OpenWFEru is at :

    Please don’t post a “homework question” though :

    I will help you do your work but I will not do if for you.

    Best regards,


    John Mettraux

    March 21, 2007 at 11:04 pm

Comments are closed.

%d bloggers like this: