Class Argv

All Implemented Interfaces:
BiVariable

public class Argv extends AbstractVariable
  • Field Details

  • Constructor Details

    • Argv

      private Argv(RubyObject receiver, String name, Object... javaObjects)
    • Argv

      Argv(RubyObject receiver, String name, IRubyObject irubyObject)
      A constructor used when ARGV is retrieved from Ruby.
      Parameters:
      receiver - a receiver object that this variable/constant is originally in. When the variable/constant is originated from Ruby, receiver may not be null.
      name - the constant name
      irubyObject - Ruby constant object
  • 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 an ARGV is put in BiVariableMap.
      Parameters:
      runtime -
      name - a variable name
      javaObject - Java object that should be assigned to.
      Returns:
      the instance of Constant
    • getType

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

      public static boolean isValidName(Object name)
      Returns true if the given name is ARGV. Unless returns false.
      Parameters:
      name - is a name to be checked.
      Returns:
      true if the given name is ARGV.
    • inject

      public void inject()
      Injects ARGV values to a parsed Ruby script. This method is invoked during EvalUnit#run() is executed.
      Parameters:
      runtime - is environment where a variable injection occurs
      receiver - is the instance that will have variable injection.
    • remove

      public void remove()
      Removes this object from BiVariableMap. Also, initialize this variable in top self.
    • retrieve

      public static void retrieve(RubyObject receiver, BiVariableMap vars)
      Retrieves ARGV from Ruby after the evaluation or method invocation.
      Parameters:
      runtime - Ruby runtime
      receiver - receiver object returned when a script is evaluated.
      vars - map to save retrieved constants.
    • updateARGV

      private static void updateARGV(IRubyObject receiver, BiVariableMap vars)
    • updateRubyObject

      protected void updateRubyObject(IRubyObject rubyObject)
      Overrides:
      updateRubyObject in class AbstractVariable
    • retrieveByKey

      public static void retrieveByKey(RubyObject receiver, BiVariableMap vars, String key)
      Retrieves ARGV by key from Ruby runtime after the evaluation. This method is used when eager retrieval is off.
      Parameters:
      receiver - receiver object returned when a script is evaluated.
      vars - map to save retrieved instance variables.
      key - instace varible name
    • getJavaObject

      public Object getJavaObject()
      Description copied from interface: BiVariable
      Returns a value of the variable this object holds in Java type.
      Specified by:
      getJavaObject in interface BiVariable
      Overrides:
      getJavaObject in class AbstractVariable
      Returns:
      a value in Java type.