Color of cell array in Ruby RTF gem

I have an exercise to do as homework. I have to make a rtf file with
colored array. I’m using a rtf gem to do this. Here is documentation of
that gem
I have written something like this while ago. But coloring using
“backgroung method” doesn’t affect on file.

require 'rubygems'
require 'rtf'
include RTF

document =, 'Times New ROMAN'))

red =,0,0)
green =,255,0)

array = document.table(2, 2)
array[0][0].background(red) << "text"
array[0][1] << "text"
array[1][0] << "text"
array[1][1].background(green) << "text"'document.rtf', "w") {|f| f.write(document.to_rtf)}

Any ideas what Could I do?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs