CoreConstructors.java

  1. package org.jruby.embed.util;

  2. import org.jruby.Ruby;
  3. import org.jruby.RubyHash;
  4. import org.jruby.runtime.builtin.IRubyObject;

  5. /**
  6.  * API's which can be used by embedders to construct Ruby builtin core types.
  7.  */
  8. public class CoreConstructors {
  9.     public static RubyHash createHash(Ruby runtime, IRubyObject key, IRubyObject value) {
  10.         RubyHash hash = RubyHash.newHash(runtime);

  11.         hash.fastASet(key, value);

  12.         return hash;
  13.     }

  14.     public static RubyHash createHash(Ruby runtime, IRubyObject key1, IRubyObject value1,
  15.                                       IRubyObject key2, IRubyObject value2) {
  16.         RubyHash hash = createHash(runtime, key1, value1);

  17.         hash.fastASet(key2, value2);

  18.         return hash;
  19.     }
  20. }