Examples of RubyString


Examples of org.jruby.RubyString

        int modifiers = ((JavaClass) java_type).javaClass().getModifiers();
        return recv.getRuntime().newString(Modifier.isPublic(modifiers) ? "public" : (Modifier.isProtected(modifiers) ? "protected" : "private"));
    }

    public static IRubyObject valid_constant_name_p(IRubyObject recv, IRubyObject name) {
        RubyString sname = name.convertToString();
        if (sname.getByteList().length() == 0) {
            return recv.getRuntime().getFalse();
        }
        return Character.isUpperCase(sname.getByteList().charAt(0)) ? recv.getRuntime().getTrue() : recv.getRuntime().getFalse();
    }
View Full Code Here

Examples of org.jruby.RubyString

    public static class HistoryMethods {
        @JRubyMethod(name = {"push", "<<"}, rest = true)
        public static IRubyObject s_push(IRubyObject recv, IRubyObject[] lines) throws Exception {
            ConsoleHolder holder = getHolder(recv.getRuntime());
            for (int i = 0; i < lines.length; i++) {
                RubyString line = lines[i].convertToString();
                holder.history.addToHistory(line.getUnicodeValue());
            }
            return recv.getRuntime().getNil();
        }
View Full Code Here

Examples of org.jruby.RubyString

            return RubyString.newString(runtime,(ByteList)super.constructScalar(node));
        } else {
            // Assume it's a mapping node

            Map val = (Map)(constructMapping(node));
            RubyString str = (RubyString)val.get(runtime.newString("str"));

            Map props = new HashMap();
            for(Iterator iter = val.entrySet().iterator();iter.hasNext();) {
                Map.Entry em = (Map.Entry)iter.next();
                if(em.getKey().toString().startsWith("@")) {
                    props.put(em.getKey(),em.getValue());
                    iter.remove();
                }
            }
            for(Iterator iter = props.entrySet().iterator();iter.hasNext();) {
                Map.Entry em = (Map.Entry)iter.next();
                str.instance_variable_set((IRubyObject)em.getKey(),(IRubyObject)em.getValue());
            }

            return str;
        }
    }
View Full Code Here

Examples of org.jruby.RubyString

        if(slen < buflen) {
            buflen = slen;
        }
        byte[] outp = new byte[buflen];
        str.get(outp);
        RubyString _str = context.getRuntime().newString(new ByteList(outp, 0, buflen, false));

        return context.getRuntime().newArrayNoCopy(new IRubyObject[]{_str, unixaddr(context.getRuntime(), buf, alen)});
    }
View Full Code Here

Examples of org.jruby.RubyString

   
    // Special form of sprintf that returns a RubyString and handles
    // tainted strings correctly.
    public static RubyString sprintf(Ruby runtime, Locale locale, CharSequence format, IRubyObject args) {
        Buffer b = rubySprintfToBuffer(format, new Args(locale,args));
        RubyString s = runtime.newString(b.toByteList());
        if (b.tainted) {
            s.setTaint(true);
        }
        return s;
    }
View Full Code Here

Examples of org.jruby.RubyString

            addPath((String) iter.next());
        }

        // add $RUBYLIB paths
       RubyHash env = (RubyHash) runtime.getObject().fastGetConstant("ENV");
       RubyString env_rubylib = runtime.newString("RUBYLIB");
       if (env.has_key_p(env_rubylib).isTrue()) {
           String rubylib = env.op_aref(runtime.getCurrentContext(), env_rubylib).toString();
           String[] paths = rubylib.split(File.pathSeparator);
           for (int i = 0; i < paths.length; i++) {
               addPath(paths[i]);
View Full Code Here

Examples of org.jruby.RubyString

        }
    }
   
    private boolean tryLoadingLibraryOrScript(Ruby runtime, SearchState state) {
        // attempt to load the found library
        RubyString loadNameRubyString = RubyString.newString(runtime, state.loadName);
        try {
            addLoadedFeature(loadNameRubyString);
           
            // otherwise load the library we've found
            state.library.load(runtime, false);
View Full Code Here

Examples of org.jruby.RubyString

        }
   
        public void trySearch(SearchState state) throws AlreadyLoaded {
            for (String suffix : state.suffixType.getSuffixes()) {
                String searchName = state.searchFile + suffix;
                RubyString searchNameString = RubyString.newString(runtime, searchName);
                if (featureAlreadyLoaded(searchNameString)) {
                    throw new AlreadyLoaded(searchNameString);
                }
            }
        }
View Full Code Here

Examples of org.jruby.RubyString

        registerLinkTarget(value);
        IRubyObject dumpResult = value.callMethod(runtime.getCurrentContext(), "_dump", runtime.newFixnum(depthLimit));
        if (!(dumpResult instanceof RubyString)) {
            throw runtime.newTypeError(dumpResult, runtime.getString());
        }
        RubyString marshaled = (RubyString)dumpResult;

        boolean hasVars;
        if (hasVars = marshaled.hasVariables()) {
            write(TYPE_IVAR);
        }

        write(TYPE_USERDEF);
        RubyClass metaclass = value.getMetaClass().getRealClass();

        dumpObject(RubySymbol.newSymbol(runtime, metaclass.getName()));

        writeString(marshaled.getByteList());

        if (hasVars) {
            dumpVariables(marshaled.getVariableList());
        }
    }
View Full Code Here

Examples of org.jruby.RubyString

        ByteList marshaled = unmarshalString();
        RubyModule classInstance = findClass(className);
        if (!classInstance.respondsTo("_load")) {
            throw runtime.newTypeError("class " + classInstance.getName() + " needs to have method `_load'");
        }
        RubyString data = RubyString.newString(getRuntime(), marshaled);
        if (ivarsWaiting) {
            defaultVariablesUnmarshal(data);
            ivarsWaiting = false;
        }
        IRubyObject result = classInstance.callMethod(getRuntime().getCurrentContext(),
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.