Package org.jruby

Examples of org.jruby.RubyHash$FoundPair


  assertEquals("[[0, \"a\"], [100, \"n\"], [200, \"d\"], [300, \"y\"]]",
         eval("p $h_invert.invert.sort"));
    }
   
    public void testGet() {
        RubyHash rubyHash = new RubyHash(Ruby.getGlobalRuntime());
        assertEquals(null, rubyHash.get("Non matching key"));
    }
View Full Code Here


        return createList(listNode);
    }
   
    @Override
    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        RubyHash hash = RubyHash.newHash(runtime);
       
        ListNode list = this.listNode;
        if (list != null) {
            int size = list.size();
  
View Full Code Here

    }

    @Override
    public Object retrieve(InterpreterContext interp) {
        Ruby runtime = interp.getRuntime();
        RubyHash hash = RubyHash.newHash(runtime);

        for (KeyValuePair pair : pairs) {
            hash.fastASetCheckString(runtime, (IRubyObject) pair.getKey().retrieve(interp),
                    (IRubyObject) pair.getValue().retrieve(interp));
        }

        return hash;
    }
View Full Code Here

    private static String[] getCurrentEnv(Ruby runtime) {
        return getCurrentEnv(runtime, null);
    }

    private static String[] getCurrentEnv(Ruby runtime, Map mergeEnv) {
        RubyHash hash = (RubyHash)runtime.getObject().fastGetConstant("ENV");
        String[] ret;
       
        if (mergeEnv != null && !mergeEnv.isEmpty()) {
            ret = new String[hash.size() + mergeEnv.size()];
        } else {
            ret = new String[hash.size()];
        }

        int i=0;
        for(Map.Entry e : (Set<Map.Entry>)hash.directEntrySet()) {
            ret[i] = e.getKey().toString() + "=" + e.getValue().toString();
            i++;
        }
        if (mergeEnv != null) for(Map.Entry e : (Set<Map.Entry>)mergeEnv.entrySet()) {
            ret[i] = e.getKey().toString() + "=" + e.getValue().toString();
View Full Code Here

        }
        return pathFile;
    }

    private static File findPathExecutable(Ruby runtime, String fname) {
        RubyHash env = (RubyHash) runtime.getObject().fastGetConstant("ENV");
        IRubyObject pathObject = env.op_aref(runtime.getCurrentContext(), RubyString.newString(runtime, PATH_ENV));
        String[] pathNodes = null;
        if (pathObject == null) {
            pathNodes = DEFAULT_PATH; // ASSUME: not modified by callee
        }
        else {
View Full Code Here

    }
   
    public static final int MAX_SPECIFIC_ARITY_HASH = 3;
   
    public static RubyHash constructHash(Ruby runtime, IRubyObject key1, IRubyObject value1) {
        RubyHash hash = RubyHash.newHash(runtime);
        hash.fastASetCheckString(runtime, key1, value1);
        return hash;
    }
View Full Code Here

        hash.fastASetCheckString(runtime, key1, value1);
        return hash;
    }
   
    public static RubyHash constructHash(Ruby runtime, IRubyObject key1, IRubyObject value1, IRubyObject key2, IRubyObject value2) {
        RubyHash hash = RubyHash.newHash(runtime);
        hash.fastASetCheckString(runtime, key1, value1);
        hash.fastASetCheckString(runtime, key2, value2);
        return hash;
    }
View Full Code Here

        hash.fastASetCheckString(runtime, key2, value2);
        return hash;
    }
   
    public static RubyHash constructHash(Ruby runtime, IRubyObject key1, IRubyObject value1, IRubyObject key2, IRubyObject value2, IRubyObject key3, IRubyObject value3) {
        RubyHash hash = RubyHash.newHash(runtime);
        hash.fastASetCheckString(runtime, key1, value1);
        hash.fastASetCheckString(runtime, key2, value2);
        hash.fastASetCheckString(runtime, key3, value3);
        return hash;
    }
View Full Code Here

        hash.fastASetCheckString(runtime, key3, value3);
        return hash;
    }
   
    public static RubyHash constructHash19(Ruby runtime, IRubyObject key1, IRubyObject value1) {
        RubyHash hash = RubyHash.newHash(runtime);
        hash.fastASetCheckString19(runtime, key1, value1);
        return hash;
    }
View Full Code Here

        hash.fastASetCheckString19(runtime, key1, value1);
        return hash;
    }
   
    public static RubyHash constructHash19(Ruby runtime, IRubyObject key1, IRubyObject value1, IRubyObject key2, IRubyObject value2) {
        RubyHash hash = RubyHash.newHash(runtime);
        hash.fastASetCheckString19(runtime, key1, value1);
        hash.fastASetCheckString19(runtime, key2, value2);
        return hash;
    }
View Full Code Here

TOP

Related Classes of org.jruby.RubyHash$FoundPair

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.