Rootroute ruby language pages |
You can try using irb
. The following is paraphrased from Goto
Kentaro (Gotoken), and originally appeared in ruby-talk:444.
irb
directory tree.
irb/
directory to the $RUBYLIB
environment variable
irb
somewhere in your path.
chmod +x $RUBYLIB/irb/irb.rb
rehash
to tell your login shell about the
new command.
irb
If the readline
extension module works with your interpreter,
it makes irb
a lot more fun to use.
There is also a simple program, eval
, in the samples/
directory of the Ruby distribution. It lets you enter expressions and
view their values. You can copy eval
into the
site_ruby
directory in the Ruby tree, and then invoke it
using:
ruby -r eval -e0 |
There is a gdb-like debugger for Ruby.
ruby -r debug your_program |
Of all the scripting languages, Ruby is probably the easiest to extend. There are no problems with reference counting and variable types, and very few interfaces to learn. In fact, C code used to extend Ruby often ends up looking surprisingly like Ruby code itself.
First, get the Ruby source distribution and read README.EXT. This is a good document, not only if you're writing an extension library, but also if you want to understand Ruby more deeply.
Next, have a look at the source of the interpreter itself, and at the
various supplied extensions in the ext/
directory.
You'll also find good examples under contrib/
on the Ruby ftp sites.
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 very close to that
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 closer to the style of the Tk
interface provided by the Perl and Python interfaces.
Your Tk version may be old, try a newer version.
gtk+
or xforms
interfaces in Ruby?
You'll find ruby-gtk-x.xx.tar.gz
and
ruby-forms-x.x.tar.gz
under contrib/
in ftp sites.
A Time object can express only the dates between Jan 1, 1970 and Jan 19, 2038.
Two standard extension library modules are provided:
require "date"
, which is simple and uses the
English calendar, and require "date2"
, which is
more general purpose.
Also see sample/cal.rb
.