Class TransientLocalVariable

java.lang.Object
org.jruby.embed.variable.AbstractVariable
org.jruby.embed.variable.TransientLocalVariable
All Implemented Interfaces:
BiVariable

public class TransientLocalVariable extends AbstractVariable
An implementation of BiVariable for a transient local variable. This type of a local variable is available during only one evaluation. After the evaluation, the variable vanishes.
  • Field Details

  • Constructor Details

    • TransientLocalVariable

      private TransientLocalVariable(RubyObject receiver, String name, Object... javaObjects)
  • Method Details

    • getInstance

      public static BiVariable getInstance(RubyObject receiver, String name, Object... javaObject)
      Returns an instance of this class. This factory method is used when a transient local variable is put in BiVariableMap.
      Parameters:
      runtime - Ruby runtime
      name - a variable name
      javaObject - Java object that should be assigned to.
      Returns:
      the instance of TransientLocalVariable
    • getType

      public BiVariable.Type getType()
      Returns enum type of this variable defined in BiVariable.
      Returns:
      this enum type, BiVariable.Type.LocalVariable.
    • isValidName

      public static boolean isValidName(Object name)
      Returns true if the given name is a decent Ruby local variable. Unless returns false.
      Parameters:
      name - is a name to be checked.
      Returns:
      true if the given name is of a Ruby local variable.
    • retrieve

      public static void retrieve(RubyObject receiver, BiVariableMap vars)
      Doesn't do anything since a transient local variable should not be retrieved from Ruby.
      Parameters:
      runtime - Ruby runtime
      receiver - receiver object returned when a script is evaluated.
      vars - map to save retrieved local variables.
    • inject

      public void inject()
      Injects a local variable value to a parsed Ruby script. This method is invoked during EvalUnit#run() is executed.
    • remove

      public void remove()
      Attempts to remove this variable from top self or receiver.