Previous Next Table of contents

8. Extension library

8.1 How can I use Ruby interactively?

Get irb-x.x.x.tgz under directory contrib/ from an ftp site. Follow install steps given by gotoken in [ruby-talk:00444]. Usage is in [ruby-talk:00447].

8.2 Is there a debugger for Ruby?

There is a debugger like gdb for Ruby. Invoke Ruby like this.
  ruby -r debug your_script

8.3 How can I use a library written in C from Ruby?

Ruby is written in C, and there are useful functions for utilizing C library from Ruby. It is easy(!) to make a Ruby extension library to use C library.

First, read README.EXT in the source directory of Ruby. It is a good document not only for writing an extension library but also to undestande Ruby more deeply.

Next, look at the subdirectories under ext/ directory. There are good examples under contrib/ in ftp sites, also.

8.4 Can I use Tcl/Tk interface in Ruby?

There are two interfaces to Tcl/Tk included in the standard distribution. One is under ext/tcltk/ and loaded with require "tcltk". The syntax is almost written as in Tcl, which is passed to Tcl interpreter. Unfortunately, the description for this library is written in Japanese.

The other is under ext/tk/ and loaded with require "tk". Its syntax is more like Ruby, which is transformed to Tcl script and passed to Tcl.

8.5 Tk won't work.

Your Tk version may be old. Change to a newer version.

8.6 Can I use gtk+ or xforms interface in Ruby?

Under contrib/ in ftp sites, there are ruby-gtk-x.xx.tar.gz and ruby-forms-x.x.tar.gz.

8.7 How can I calculate dates?

A Time object can express only the dates between Jan 1, 1970 and Jan 19, 2038. Use standard extension library by require "date" or require "date2". date.rb is fixed to use English calendar, while date2.rb is for general purpose. Please also refer sample/cal.rb.
Previous Next Table of contents