Embed applicaiton INSIDE ruby

Call me wierd. I just wonder how could one embed the other application
inside Ruby code. To be exact, if I have used Ruby/Tk to build
an user interface, how do I embed the application side the Ruby interface?
( assuming the other application also has its own interface)

Use Microsoft Windows system as an example.(yack… but what can I do)

Thanks.

HH

hhcNYC wrote:

Call me wierd. I just wonder how could one embed the other application
inside Ruby code. To be exact, if I have used Ruby/Tk to build
an user interface, how do I embed the application side the Ruby interface?
( assuming the other application also has its own interface)

You create a Ruby extension module for it. Usually, when people talk
about “embedding” they’re referring to embedding a Ruby interpreter into
some other application. In contrast, “extending” Ruby refers to writing
C/C++ code that Ruby can import at runtime and use just like native Ruby
code.

For more information, see the “Extending Ruby” chapter in Programming Ruby:

http://www.rubycentral.com/book/ext_ruby.html

Hope this helps,

Lyle

Hi.

hhcNYC@yahoo.com (hhcNYC) did say …

Call me wierd. I just wonder how could one embed the other application
inside Ruby code. To be exact, if I have used Ruby/Tk to build
an user interface, how do I embed the application side the Ruby
interface? ( assuming the other application also has its own
interface)

There are a number of ways that you could go about doing this:

  1. Write the application in C and then write a Ruby extension
    to interface to the code (this is covered in the Pickaxe
    book).

  2. Take an existing API from the other application and use a
    toolkit like SWIG (www.swig.org) to write the Ruby interface
    for you (like (1) except more automated).

  3. Embed a language interpreter within Ruby that isn’t ruby, and
    write your application in that language (like the ratlast
    system that I wrote that handles a FORTH-like language, or
    REXML et al that handles XML).

  4. Roll your own language interpreter using a parser-scanner
    (ryacc/rlex, ralli, etc.) and then go from there.

There are probably others that brighter minds than mine can
think of … The easiest way is probably (2) though YMMV :wink:

Regards,

···


-mark.


Mark Probert probertm@NOSPAM_nortelnetworks.com
Nortel Networks ph. (613) 768-1082

All opinions expressed are my own and do not
reflect in any way those of Nortel Networks.

Thanks to you all!

HH