Array's in rules gives != operator is not allowed.

13 views
Skip to first unread message

Richard Pruss

unread,
Aug 31, 2009, 1:44:43 AM8/31/09
to Ruleby
I am trying to use Ruleby to parse some data, but I run into a strange
error.
"/Library/Ruby/Gems/1.8/gems/ruleby-0.5/lib/dsl/ferrari.rb:96:in
`when': The != operator is not allowed. (RuntimeError)"

Can one refer to an array in a rule.

class Line
def initialize(linein)
@rows = linein.chop.split(',')
@size = @rows.length
puts "Init line of #{@size} from #{@rows}"
end
attr_reader :rows,:size
def to_s
return @rows.to_s;
end
end

Here is the rule I am trying, I remove the array reference this works:

rule :ThreeinFourParse,
[Line,:line, m.size>=15,m.row[4]==3, {m.rows => :r}] do |vars|
rows = vars[:r]
puts "Rule fired for for #{rows}"
end

The array reference I suspect is not allowed, is that the case?

/Library/Ruby/Gems/1.8/gems/ruleby-0.5/lib/dsl/ferrari.rb:96:in
`when': The != operator is not allowed. (RuntimeError)
from /Library/Ruby/Gems/1.8/gems/ruleby-0.5/lib/dsl/ferrari.rb:81:in
`each'
from /Library/Ruby/Gems/1.8/gems/ruleby-0.5/lib/dsl/ferrari.rb:81:in
`when'
from /Library/Ruby/Gems/1.8/gems/ruleby-0.5/lib/dsl/ferrari.rb:27:in
`rule'
from /Library/Ruby/Gems/1.8/gems/ruleby-0.5/lib/dsl/ferrari.rb:25:in
`each'
from /Library/Ruby/Gems/1.8/gems/ruleby-0.5/lib/dsl/ferrari.rb:25:in
`rule'
from /Library/Ruby/Gems/1.8/gems/ruleby-0.5/lib/rulebook.rb:51:in
`rule'
from ./lib/ParseLine.rb:87:in `rules'
from ./lib/FileTail.rb:40:in `file_tail'
from /Library/Ruby/Gems/1.8/gems/ruleby-0.5/lib/ruleby.rb:19:in
`engine'
from ./lib/FileTail.rb:39:in `file_tail'
from ./ee.rb:143:in `process_command'
from ./ee.rb:72:in `run'
from ./ee.rb:168

-Ric

Joe Kutner

unread,
Aug 31, 2009, 11:46:46 AM8/31/09
to rul...@googlegroups.com
Yea, accessing arrays like that isn't supported yet. But you can use
a block condition such as:

m.row($c{ |r| r[4] == 3})

Joe Kutner

unread,
Aug 31, 2009, 11:47:38 AM8/31/09
to rul...@googlegroups.com
btw, i'm not sure why you got the != error. I look into why it gives
the wrong error message.

Richard Pruss

unread,
Aug 31, 2009, 10:39:01 PM8/31/09
to rul...@googlegroups.com
Yep, that works. Thanks for the help and of course thanks for the
wonderful engine,
Ric
Reply all
Reply to author
Forward
0 new messages