Exemple #1
0
 @Override
 public RubyHash to_hash() {
   Ruby runtime = getRuntime();
   RubyHash hash = RubyHash.newHash(runtime);
   hash.replace(runtime.getCurrentContext(), this);
   return hash;
 }
Exemple #2
0
  @SuppressWarnings("unchecked")
  private static void defineGlobalEnvConstants(Ruby runtime) {
    Map<RubyString, RubyString> environmentVariableMap =
        OSEnvironment.environmentVariableMap(runtime);
    RubyHash env =
        new CaseInsensitiveStringOnlyRubyHash(
            runtime,
            environmentVariableMap,
            runtime.getNil(),
            runtime.getInstanceConfig().isNativeEnabled()
                && runtime.getInstanceConfig().isUpdateNativeENVEnabled());
    env.getSingletonClass().defineAnnotatedMethods(CaseInsensitiveStringOnlyRubyHash.class);
    runtime.defineGlobalConstant("ENV", env);
    runtime.setENV(env);

    // Define System.getProperties() in ENV_JAVA
    Map<RubyString, RubyString> systemPropertiesMap = OSEnvironment.systemPropertiesMap(runtime);
    RubyHash envJava =
        new ReadOnlySystemPropertiesHash(runtime, systemPropertiesMap, runtime.getNil());
    envJava.setFrozen(true);
    runtime.defineGlobalConstant("ENV_JAVA", envJava);
  }