I want to include all the ruby files in a directory that implement the function toto().
In python I will do:
res = []
for f in glob.glob("*.py"):
i = __import__(f)
if "toto" in dir(i):
res.append(i.toto)
and I could use the list like this:
for toto in res:
toto()
In Ruby imports are very different than in Python – in Python files and modules are more or less the same thing, in Ruby they are not. You’ll have to create your modules manually:
Or maybe more Ruby idiomatic: