Jafar
Ruby and Jafar

Configure your environnement for Ruby

Enabling building of Ruby binding in jafar

The first step is to enable the build of Ruby modules in jafar. It is done using -DENABLE_RUBY=ON at configure time:

cd $JAFAR_DIR
./cmake -DENABLE_RUBY=ON other_cool_params .
cd -

Then you need to issue a build command in your modules.

cd $JAFAR_DIR
make
cd -

Environnement variable

You need to define RUBYLIB for ruby to find your modules. In bash:

export RUBYLIB="$JAFAR_DIR/lib/i686-linux-gnu/ruby/1.8/"

In tcsh:

setenv RUBYLIB "$JAFAR_DIR/lib/i686-linux-gnu/ruby/1.8/"

The Ruby shell

irb

The standard ruby shell is called 'irb', if you have followed the instructions above, you can now start to use ruby and jafar together, after starting irb, you can type the following code:

require 'jafar/kernel' # load the module kernel of jafar
include Jafar # equivalent of using namespace in C++, you won't need to start all your command with Jafar::

Note, that there is allready a Kernel module in the Core library of Ruby. So to access the function in the Kernel module of Jafar, you need to give the full path. For instance:

Jafar::Kernel::DebugStream.moduleOff("gfm") # it will disable the debugging in gfm
Kernel::DebugStream.moduleOff("gfm") # will throw an error telling that DebugStream is not a member of the Kernel module

The configuration file of the IRB is $HOME/.irbrc.

The jafar Ruby Shell

If you want to use the module qdisplay. You need to use the jfrirb shell.

jfrirb

This shell requires the Qt4 ruby bindings:

On debian/ubuntu:

apt-get install libqt4-ruby

On Fedora Core:

yum install QtRuby

From source: Download them from rubyforge.

Configuration file

The configuration file of the jrb and jfrirb shells is $HOME/.jrbrc. For instance mine looks like this:

def reload()
  load 'jafar/image.rb'
  load 'jafar/qdisplay.rb'
  load 'jafar/gfm.rb'
  load 'jafar/preprocessing.rb'
  load 'jafar/geom.rb'
  load 'jafar/datareader.rb'
  load 'jafar/facetsmap.rb'
  load 'jafar/viewer3d.rb'
end

reload()

# Define the default data series for the datareader
Jafar::Datareader::DataReader.setDefaultSeriesName("2005_11_bouclage_newspec")
Jafar::Datareader::DataReader.setDefaultSerieNumber(11)

Usefull links about ruby

The official ruby site is www.ruby-lang.org.

Documentation about ruby

Ressources

About IRB

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:30 for Jafar by doxygen 1.7.6.1
LAAS-CNRS