Package org.jruby.runtime.builtin

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


   
    private static IRubyObject str_to_c_strict(ThreadContext context, IRubyObject recv) {
        RubyArray a = str_to_c_internal(context, recv);
        if (a.eltInternal(0).isNil() || a.eltInternal(1).convertToString().getByteList().length() > 0) {
            IRubyObject s = recv.callMethod(context, "inspect");
            throw context.runtime.newArgumentError("invalid value for convert(): " + s.convertToString());
        }
        return a.eltInternal(0);
    }   
}
View Full Code Here


            return in.read();
        }
        IRubyObject readValue = readAdapter.call(io.getRuntime().getCurrentContext(), io, io, numOne);
        int returnValue = -1;
        if (!readValue.isNil()) {
            returnValue = readValue.convertToString().getByteList().get(0) & 0xff;
        }
        return returnValue;
    }

    @Override
View Full Code Here

            return in.read(b, 0, b.length);
        }
        IRubyObject readValue = readAdapter.call(io.getRuntime().getCurrentContext(), io, io, io.getRuntime().newFixnum(b.length));
        int returnValue = -1;
        if (!readValue.isNil()) {
            ByteList str = readValue.convertToString().getByteList();
            System.arraycopy(str.getUnsafeBytes(), str.getBegin(), b, 0, str.getRealSize());
            returnValue = str.getRealSize();
        }
        return returnValue;
    }
View Full Code Here

            return in.read(b, off, len);
        }
        IRubyObject readValue = readAdapter.call(io.getRuntime().getCurrentContext(), io, io, io.getRuntime().newFixnum(len));
        int returnValue = -1;
        if (!readValue.isNil()) {
            ByteList str = readValue.convertToString().getByteList();
            System.arraycopy(str.getUnsafeBytes(), str.getBegin(), b, off, str.getRealSize());
            returnValue = str.getRealSize();
        }
        return returnValue;
     }
View Full Code Here

        }

        String zone = "";
        if (zoneVar != null && zoneVar.respondsTo("to_str")) {
            try {
                zone = zoneVar.convertToString().toString();
            } catch (RaiseException typeError) {
            }
        }

        time.dt = dt.withZone(getTimeZoneWithOffset(runtime, zone, offset));
View Full Code Here

                }
                IRubyObject tmp = args[0].checkStringType();
                if (tmp.isNil()) {
                    limit = RubyNumeric.fix2int(args[0]);
                } else {
                    sep = tmp.convertToString().getByteList();
                }
                break;
            case 2:
            default:
                limit = RubyNumeric.fix2int(args[1]);
View Full Code Here

        RubyHash optHash2 = (RubyHash)opthash;
        ecflags = econvOpts(context, opthash, ecflags);
       
        v = optHash2.op_aref(context, context.runtime.newSymbol("replace"));
        if (!v.isNil()) {
            RubyString v_str = v.convertToString();
            if (v_str.scanForCodeRange() == StringSupport.CR_BROKEN) {
                throw context.runtime.newArgumentError("replacement string is broken: " + v_str);
            }
            v = v_str.freeze(context);
            newhash = RubyHash.newHash(context.runtime);
View Full Code Here

                                runtime.getEncodingService().findEncodingOrAliasEntry(ec.lastError.getSource()).getEncoding(),
                                false)
                );
                rep = fallbackFunc.call(context, fallback, rep);
                if (!rep.isNil()) {
                    rep = rep.convertToString();
                    Encoding repEnc = ((RubyString)rep).getEncoding();
                    ByteList repByteList = ((RubyString)rep).getByteList();
                    ec.insertOutput(repByteList.getUnsafeBytes(), repByteList.begin(), repByteList.getRealSize(), repEnc.getName());

                    // TODO: check for too-large replacement
View Full Code Here

        while (!current.op_equal19(context, afterEnd).isTrue()) {
            IRubyObject next = null;
            if (excl || !current.op_equal19(context, end).isTrue()) next = current.callMethod(context, "succ");
            block.yield(context, asSymbol ? runtime.newSymbol(current.toString()) : current);
            if (next == null) break;
            current = next.convertToString();
            if (excl && current.op_equal19(context, end).isTrue()) break;
            if (current.getByteList().length() > end.getByteList().length() || current.getByteList().length() == 0) break;
        }
        return this;
    }
View Full Code Here

   
    private static IRubyObject str_to_r_strict(ThreadContext context, IRubyObject recv) {
        RubyArray a = str_to_r_internal(context, recv);
        if (a.eltInternal(0).isNil() || a.eltInternal(1).convertToString().getByteList().length() > 0) {
            IRubyObject s = recv.callMethod(context, "inspect");
            throw context.runtime.newArgumentError("invalid value for convert(): " + s.convertToString());
        }
        return a.eltInternal(0);
    }

    /**
 
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.