Package org.jruby.runtime.builtin

Examples of org.jruby.runtime.builtin.IRubyObject.asJavaString()


                        if (!(methodName instanceof RubyString)) {
                            throw runtime.newTypeError(
                                    "invalid method name defined for proxy (or ancestor): " +
                                    ancestor + ": " + methodName);
                        }
                        names.add(methodName.asJavaString());
                    }
                }
            } else if (!EXCLUDE_MODULES.contains(ancestor.getName())) {
                Map<String, DynamicMethod> methods;
                synchronized(methods = ancestor.getMethods()) {
View Full Code Here


            if (args.length > 3 && args[3] instanceof RubyHash) {
                RubyHash options = (RubyHash) args[3];
                IRubyObject byte_order = options.fastARef(RubySymbol.newSymbol(context.runtime, "byte_order"));
                if (byte_order instanceof RubySymbol || byte_order instanceof RubyString) {
                    String orderName = byte_order.asJavaString();
                    if ("network".equals(orderName) || "big".equals(orderName)) {
                        order = ByteOrder.BIG_ENDIAN;
                   
                    } else if ("little".equals(orderName)) {
                        order = ByteOrder.LITTLE_ENDIAN;
View Full Code Here

    @JRubyMethod(name = "const_defined?", required = 1, optional = 1, compat = RUBY1_9)
    public RubyBoolean const_defined_p19(ThreadContext context, IRubyObject[] args) {
        IRubyObject symbol = args[0];
        boolean inherit = args.length == 1 || (!args[1].isNil() && args[1].isTrue());

        return context.runtime.newBoolean(fastIsConstantDefined19(validateConstant(symbol.asJavaString()).intern(), inherit));
    }

    /** rb_mod_const_get
     *
     */
 
View Full Code Here

    public IRubyObject const_get_1_9(ThreadContext context, IRubyObject[] args) {
        IRubyObject symbol = args[0];
        boolean inherit = args.length == 1 || (!args[1].isNil() && args[1].isTrue());

        // 1.9 only includes Object when inherit = true or unspecified (JRUBY-6224)
        return getConstant(validateConstant(symbol.asJavaString()), inherit, inherit);
    }

    @JRubyMethod(name = "const_get", required = 1, optional = 1, compat = CompatVersion.RUBY2_0)
    public IRubyObject const_get_2_0(ThreadContext context, IRubyObject[] args) {
        String symbol = args[0].asJavaString();
View Full Code Here

                if (runtime.is1_9()
                        && (object instanceof RubyString || object instanceof RubyRegexp)
                        && count >= 1) { // 1.9 string encoding
                    EncodingCapable strObj = (EncodingCapable)object;

                    if (key.asJavaString().equals(MarshalStream.SYMBOL_ENCODING_SPECIAL)) {
                        // special case for USASCII and UTF8
                        if (unmarshalObject().isTrue()) {
                            strObj.setEncoding(UTF8Encoding.INSTANCE);
                        } else {
                            strObj.setEncoding(USASCIIEncoding.INSTANCE);
View Full Code Here

                            strObj.setEncoding(UTF8Encoding.INSTANCE);
                        } else {
                            strObj.setEncoding(USASCIIEncoding.INSTANCE);
                        }
                        continue;
                    } else if (key.asJavaString().equals("encoding")) {
                        // read off " byte for the string
                        read();
                        ByteList encodingName = unmarshalString();
                        Entry entry = runtime.getEncodingService().findEncodingOrAliasEntry(encodingName);
                        if (entry == null) {
View Full Code Here

                        strObj.setEncoding(encoding);
                        continue;
                    } // else fall through as normal ivar
                }
            }
            String name = key.asJavaString();
            IRubyObject value = unmarshalObject();

            cls.getVariableAccessorForWrite(name).set(object, value);
        }
    }
View Full Code Here

                    JavaExtractor.instance.extractFrom(((RubyNumeric) iro).getBigIntegerValue()));
        if(iro instanceof RubyString)
            return new SimpleDebugObject(null, iro.getType().toString(),
                    JavaExtractor.instance.extractFrom(((RubyString) iro).getUnicodeValue()));
        if(iro instanceof RubySymbol)
            return new SimpleDebugObject(null, iro.getType().toString(), ":" + iro.asJavaString());

        RubyClass clazz = iro.getType();
        List<String> names = iro.getVariableNameList();
        List<Variable<Object>> values = iro.getVariableList();
        SimpleDebugObject dobj =  new SimpleDebugObject(null, iro.getType().toString(), iro);
View Full Code Here

                String keyAsJava = keyAsStr.asJavaString();
                // libc (un)setenv is not reentrant, so we need to synchronize across the entire JVM (JRUBY-5933)
                if (valueAsStr == getRuntime().getNil()) {
                    synchronized (Object.class) { posix.unsetenv(keyAsJava); }
                } else {
                    synchronized (Object.class) { posix.setenv(keyAsJava, valueAsStr.asJavaString(), 1); }
                }
            }

            return super.op_aset(context, keyAsStr, valueAsStr);
View Full Code Here

           
            for (int i = 0; i < openArgs.size(); i++) {
                IRubyObject arg = openArgs.eltInternal(i);
               
                if (arg instanceof RubyString) { // Overrides all?
                    ioOptions = newIOOptions(runtime, arg.asJavaString());
                } else if (arg instanceof RubyFixnum) {
                    ioOptions = newIOOptions(runtime, ((RubyFixnum) arg).getLongValue());
                } else if (arg instanceof RubyHash) {
                    ioOptions = updateIOOptionsFromOptions(context, (RubyHash) arg, ioOptions);
                }
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.