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 http://ruby-rtf.rubyforge.org/docs/.
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 = Document.new(Font.new(Font::ROMAN, 'Times New ROMAN'))

red = Colour.new(255,0,0)
green = Colour.new(0,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"

File.open('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