Customize a gem method

Hello,
I want to customize a method of a gem wuthout changing the source code
of this gem .
Is that possible?
Thanks

On Thu, May 29, 2008 at 9:42 AM, Abir B. [email protected] wrote:

Hello,
I want to customize a method of a gem wuthout changing the source code
of this gem .
Is that possible?

Sure is:

require ‘rubygems’
require ‘pdf/writer’

w = PDF::Writer.new
w.text_width(“Hello World”) # => 51.67

class PDF::Writer
def text_width(s)
42.0
end
end
w.text_width(“Hello World”) # => 42.0

Regards,
Sean