patch from Steven Jenkins -------
[comedilib.git] / swig / ruby / README
1 This directory contains files for building a Ruby extension library
2 for Comedi.
3
4 Instructions for building by hand (you shouldn't need to do this):
5
6     1.  Type 'ruby setup.rb config'. This configures for the local
7         environment.
8
9     2.  Type 'ruby setup.rb setup'. This builds the extension library.
10
11     3.  Type 'ruby setup.rb install'. This installs the extension
12         library and the file lib/comedi.rb, which provides more
13         Ruby-like method syntax.
14
15 The file 'lib/comedi.rb' provides syntactic sugar in four forms:
16
17 1.  Method names without the 'comedi_' prefix. The Comedi module
18     disambiguates the namespace. For example, you can say
19     'dev = Comedi::open()' instead of 'dev = Comedi::comedi_open()'.
20
21 2.  Instance methods that take an explicit receiver instead of
22     expecting the target object as an initial argument. For example:
23     'comedi_close(dev)' can be written as 'dev.close'.
24
25 3.  A pre-defined IO object and an accessor method to simplify
26     reading from the file descriptor associated with the comedi device.
27     Data from comedi device 'dev' can be read by 'dev.ios.read'.
28
29 4.  A ComediError exception class. If the underlying comedi
30     function returns an error indication, the ruby method will raise
31     ComediError.
32
33 The file 'demo/cmd' is a straight port of 'cmd.c' from the
34 Comedilib 'demo' directory. It illustrates the basics of programming
35 Comedi commands using Ruby.
36
37 If a Comedilib function returns a value through a pointer passed as an
38 input parameter, its Ruby counterpart returns the value as an element
39 of an Array.
40
41     ret, cmd = dev.command_test(cmd)
42
43 Because the command object is used by command_test() it appears as an
44 input parameter as well.  If the pointer is used only for output, it is
45 omitted from the parameter list. For example:
46
47     data = dev.data_read(subdevice, channel, range, aref);
48
49 Steven Jenkins
50 steven.jenkins@ieee.org
51 2004-03-02