Class RubyInterpreter

  • All Implemented Interfaces:
    AutoCloseable

    public final class RubyInterpreter
    extends be.yildizgames.module.script.ScriptInterpreter
    Ruby implementation as script interpreter.
    Author:
    Grégory Van den Borre
    • Method Summary

      Modifier and Type Method Description
      void close()  
      static RubyInterpreter concurrent()
      +------------------+ +------------------+ +------------------+ | Variable Map | | Variable Map | | Variable Map | +------------------+ +------------------+ +------------------+ +------------------------------------------------------------+ | Ruby runtime | +------------------------------------------------------------+ +------------------------------------------------------------+ | ScriptingContainer | +------------------------------------------------------------+ +------------------+ +------------------+ +------------------+ | Java Thread | | Java Thread | | Java Thread | +------------------+ +------------------+ +------------------+ +------------------------------------------------------------+ | JVM | +------------------------------------------------------------+
      Object getClassMethods​(Class<?> classToGet)  
      String getFileExtension()  
      String getFileHeader()  
      void initialize()
      Initialize the ruby engine.
      boolean isClosed()  
      void print​(String toPrint)  
      void registerClass​(Class clazz)
      Register a class to be recognized by Ruby.
      Object runCommand​(String command)  
      be.yildizgames.module.script.ParsedScript runScript​(String file)  
      void setOutput​(Writer output)  
      static RubyInterpreter singleThread()
      +------------------+ +------------------+ +------------------+ | Variable Map | | Variable Map | | Variable Map | +------------------+ +------------------+ +------------------+ +------------------+ +------------------+ +------------------+ | Ruby runtime | | Ruby runtime | | Ruby runtime | +------------------+ +------------------+ +------------------+ +------------------+ +------------------+ +------------------+ |ScriptingContainer| |ScriptingContainer| |ScriptingContainer| +------------------+ +------------------+ +------------------+ +------------------------------------------------------------+ | JVM | +------------------------------------------------------------+
      static RubyInterpreter singleton()
      +------------------------------------------------------------+ | Variable Map | +------------------------------------------------------------+ +------------------------------------------------------------+ | Ruby runtime | +------------------------------------------------------------+ +------------------+ +------------------+ +------------------+ |ScriptingContainer| |ScriptingContainer| |ScriptingContainer| +------------------+ +------------------+ +------------------+ +------------------------------------------------------------+ | JVM | +------------------------------------------------------------+
      static RubyInterpreter threadSafe()
      +------------------+ +------------------+ +------------------+ | Variable Map | | Variable Map | | Variable Map | +------------------+ +------------------+ +------------------+ +------------------+ +------------------+ +------------------+ | Ruby runtime | | Ruby runtime | | Ruby runtime | +------------------+ +------------------+ +------------------+ +------------------------------------------------------------+ | ScriptingContainer | +------------------------------------------------------------+ +------------------+ +------------------+ +------------------+ | Java Thread | | Java Thread | | Java Thread | +------------------+ +------------------+ +------------------+ +------------------------------------------------------------+ | JVM | +------------------------------------------------------------+
      • Methods inherited from class be.yildizgames.module.script.ScriptInterpreter

        getEngine
    • Method Detail

      • singleThread

        public static RubyInterpreter singleThread()
        +------------------+ +------------------+ +------------------+ | Variable Map | | Variable Map | | Variable Map | +------------------+ +------------------+ +------------------+ +------------------+ +------------------+ +------------------+ | Ruby runtime | | Ruby runtime | | Ruby runtime | +------------------+ +------------------+ +------------------+ +------------------+ +------------------+ +------------------+ |ScriptingContainer| |ScriptingContainer| |ScriptingContainer| +------------------+ +------------------+ +------------------+ +------------------------------------------------------------+ | JVM | +------------------------------------------------------------+
        Returns:
        A new RubyInterpreter with simple single thread scope.
      • concurrent

        public static RubyInterpreter concurrent()
        +------------------+ +------------------+ +------------------+ | Variable Map | | Variable Map | | Variable Map | +------------------+ +------------------+ +------------------+ +------------------------------------------------------------+ | Ruby runtime | +------------------------------------------------------------+ +------------------------------------------------------------+ | ScriptingContainer | +------------------------------------------------------------+ +------------------+ +------------------+ +------------------+ | Java Thread | | Java Thread | | Java Thread | +------------------+ +------------------+ +------------------+ +------------------------------------------------------------+ | JVM | +------------------------------------------------------------+
        Returns:
        A new RubyInterpreter with concurrent scope.
      • singleton

        public static RubyInterpreter singleton()
        +------------------------------------------------------------+ | Variable Map | +------------------------------------------------------------+ +------------------------------------------------------------+ | Ruby runtime | +------------------------------------------------------------+ +------------------+ +------------------+ +------------------+ |ScriptingContainer| |ScriptingContainer| |ScriptingContainer| +------------------+ +------------------+ +------------------+ +------------------------------------------------------------+ | JVM | +------------------------------------------------------------+
        Returns:
        A new RubyInterpreter with singleton scope.
      • threadSafe

        public static RubyInterpreter threadSafe()
        +------------------+ +------------------+ +------------------+ | Variable Map | | Variable Map | | Variable Map | +------------------+ +------------------+ +------------------+ +------------------+ +------------------+ +------------------+ | Ruby runtime | | Ruby runtime | | Ruby runtime | +------------------+ +------------------+ +------------------+ +------------------------------------------------------------+ | ScriptingContainer | +------------------------------------------------------------+ +------------------+ +------------------+ +------------------+ | Java Thread | | Java Thread | | Java Thread | +------------------+ +------------------+ +------------------+ +------------------------------------------------------------+ | JVM | +------------------------------------------------------------+
        Returns:
        A new RubyInterpreter with thread safety scope.
      • initialize

        public final void initialize()
                              throws be.yildizgames.module.script.ScriptException
        Initialize the ruby engine.
        Throws:
        be.yildizgames.module.script.ScriptException - If the initialization failed.
      • registerClass

        public final void registerClass​(Class clazz)
                                 throws be.yildizgames.module.script.ScriptException
        Register a class to be recognized by Ruby.
        Parameters:
        clazz - Class to register.
        Throws:
        be.yildizgames.module.script.ScriptException - If the class cannot be registered.
      • setOutput

        public final void setOutput​(Writer output)
        Specified by:
        setOutput in class be.yildizgames.module.script.ScriptInterpreter
      • runScript

        public final be.yildizgames.module.script.ParsedScript runScript​(String file)
                                                                  throws be.yildizgames.module.script.ScriptException
        Specified by:
        runScript in class be.yildizgames.module.script.ScriptInterpreter
        Throws:
        be.yildizgames.module.script.ScriptException
      • runCommand

        public final Object runCommand​(String command)
                                throws be.yildizgames.module.script.ScriptException
        Specified by:
        runCommand in class be.yildizgames.module.script.ScriptInterpreter
        Throws:
        be.yildizgames.module.script.ScriptException
      • getClassMethods

        public final Object getClassMethods​(Class<?> classToGet)
        Specified by:
        getClassMethods in class be.yildizgames.module.script.ScriptInterpreter
      • print

        public final void print​(String toPrint)
        Specified by:
        print in class be.yildizgames.module.script.ScriptInterpreter
      • getFileHeader

        public final String getFileHeader()
        Specified by:
        getFileHeader in class be.yildizgames.module.script.ScriptInterpreter
      • getFileExtension

        public final String getFileExtension()
        Specified by:
        getFileExtension in class be.yildizgames.module.script.ScriptInterpreter
        Returns:
        rb
      • isClosed

        public final boolean isClosed()
        Specified by:
        isClosed in class be.yildizgames.module.script.ScriptInterpreter
      • close

        public final void close()