the Ruby bindings are rather general: if dictionaries are available for a set of C++ entities (and they are for TMVA), these entites are available to Ruby.
Unfortunately no tutorial was provided which mixed Ruby and TMVA yet.
Thanks Danilo. Would you happen to have a quick example (even a one-liner) on how to access TMVA’s entities? I’m having trouble understanding how Ruby handles the TMVA namespace:
$ irb
irb(main):001:0> require '/usr/lib/root/libRuby'
=> true
irb(main):002:0> TTree
=> TTree
irb(main):003:0> TTree.ancestors
=> [TTree, DRRAbstractClass, Object, Kernel, BasicObject]
irb(main):004:0> TMVA::Factory
Warning in <TClass::TClass>: no dictionary for class TMVA is available
NameError: uninitialized constant TMVA
from (irb):4:in `const_missing'
from (irb):4
from /usr/bin/irb:12:in `<main>'
irb(main):005:0> TMVA
Warning in <TClass::TClass>: no dictionary for class TMVA is available
NameError: uninitialized constant TMVA
from (irb):5:in `const_missing'
from (irb):5
from /usr/bin/irb:12:in `<main>'
I am able now to fetch the TMVA::Factory class by directly calling DRRAbstractClass’s const_missing method (see snippet below). I’m not sure why the Ruby binding is otherwise tripping over the scope operator.
However, I have a separate issue now. The constructor of TMVA::Factory is expecting arguments of types (TString, TFile*, TString). However, in Ruby, I only know how to pass over strings of type char* and TString*:
$ irb
irb(main):001:0> require '/usr/lib/root/libRuby'
=> true
irb(main):002:0> outfile = TFile.new("/tmp/outfile.root", "recreate")
=> #<TFile:0x00000001d42e10>
irb(main):003:0> DRRAbstractClass.const_missing("TMVA::Factory")
=> TMVA::Factory
irb(main):004:0> DRRAbstractClass.const_missing("TMVA::Factory").new("jobname", outfile, "V")
ArgumentError: You provided an unknown prototype (char*,TFile*,char*) for (TMVA::Factory#TMVA::Factory).
from (irb):4:in `initialize'
from (irb):4:in `new'
from (irb):4
from /usr/bin/irb:12:in `<main>'
irb(main):005:0> jobname = TString.new("jobname")
=> #<TString:0x00000001d074c8>
irb(main):006:0> options = TString.new("V")
=> #<TString:0x00000001cff2a0>
irb(main):007:0> DRRAbstractClass.const_missing("TMVA::Factory").new(jobname, outfile, options)
ArgumentError: You provided an unknown prototype (TString*,TFile*,TString*) for (TMVA::Factory#TMVA::Factory).
from (irb):7:in `initialize'
from (irb):7:in `new'
from (irb):7
from /usr/bin/irb:12:in `<main>'
irb(main):008:0>
Is there a way to cast the arguments to the appropriate type (TString)?
Thanks Elias. That’s too bad, I hope the Ruby extension will have support for this scenario in a future release. Having access to TMVA via Ruby would be really great!