Split array fields in logstash

Thanks for pointing out the mistakes.
ruby {
code => "
times = event['id'].split(',')
times.each_index { |i| event[i.to_s] = times[i]
if times[i] == '7'
event['IndexValue'] = i}
end
"
}

Now when I run this, I get foll exception

SyntaxError: (ruby filter code):5: syntax error, unexpected tRCURLY
event['IndexValue'] = i}
^
eval at org/jruby/RubyKernel.java:1079
register at /data/logstash/vendor/bundle/jruby/1.9/gems/logstash-filter-ruby-2.0.3/lib/logstash/filters/ruby.rb:29
each at org/jruby/RubyArray.java:1613
start_filters at /data/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.1.3-java/lib/logstash/pipeline.rb:171
run at /data/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.1.3-java/lib/logstash/pipeline.rb:101
execute at /data/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.1.3-java/lib/logstash/agent.rb:165
run at /data/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.1.3-java/lib/logstash/runner.rb:90
call at org/jruby/RubyProc.java:281
run at /data/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.1.3-java/lib/logstash/runner.rb:95
call at org/jruby/RubyProc.java:281
initialize at /data/logstash/vendor/bundle/jruby/1.9/gems/stud-0.0.22/lib/stud/task.rb:24

I looked up for the exception, found a solution given by you.

ruby {
code => "
times = event["id"].split(',')
times.each_index { |i| event[i.to_s] = times[i]
if times[i] == '7'
event['IndexValue.to_i'] = i}
end
"
}

when change event['id'] from single quote to double quotes as mentioned above, it gives me foll exception

Error: Expected one of #, {, } at line 25, column 16 (byte 545)

If I comment out the complete ruby code, It works fine. Means again there is some prob with the ruby code.

Plz refer some link as well where I can study more detail on how to use ruby in logstash.