@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) { ByteList bytes = new ByteList((byte[]) ((ArrayJavaProxy) self).getObject(), ascii8bit); return RubyString.newStringLight(context.runtime, bytes); } });
@JRubyMethod(name = "alloc", meta = true) public static RubyString alloc(ThreadContext context, IRubyObject recv, IRubyObject size) { return RubyString.newStringLight(context.runtime, RubyInteger.fix2int(size)); }
protected int write(CallSite write, ByteBuffer src) throws IOException { ByteList buffer; if (src.hasArray()) { buffer = new ByteList(src.array(), src.position(), src.remaining(), true); } else { buffer = new ByteList(src.remaining()); buffer.append(src, src.remaining()); } IRubyObject written = write.call(runtime.getCurrentContext(), io, io, RubyString.newStringLight(runtime, buffer)); return (int)written.convertToInteger().getLongValue(); }
protected int write(CallSite write, ByteBuffer src) throws IOException { ByteList buffer; if (src.hasArray()) { buffer = new ByteList(src.array(), src.position(), src.remaining(), true); } else { buffer = new ByteList(src.remaining()); buffer.append(src, src.remaining()); } IRubyObject written = write.call(runtime.getCurrentContext(), io, io, RubyString.newStringLight(runtime, buffer)); return (int)written.convertToInteger().getLongValue(); }
@Override public void write(final int bite) throws IOException { if (out != null) { out.write(bite); } else { final Ruby runtime = io.getRuntime(); writeAdapter.call(runtime.getCurrentContext(), io, io, RubyString.newStringLight(runtime, new ByteList(new byte[] { (byte) bite }, encoding, false))); } }
@Override public void write(final byte[] b,final int off, final int len) throws IOException { if (out != null) { out.write(b, off, len); } else { final Ruby runtime = io.getRuntime(); writeAdapter.call(runtime.getCurrentContext(), io, io, RubyString.newStringLight(runtime, new ByteList(b, off, len, encoding, false))); } }
@Override public void write(final int bite) throws IOException { if (out != null) { out.write(bite); } else { final Ruby runtime = io.getRuntime(); writeAdapter.call(runtime.getCurrentContext(), io, io, RubyString.newStringLight(runtime, new ByteList(new byte[] { (byte) bite }, encoding, false))); } }
@Override public void write(final byte[] b,final int off, final int len) throws IOException { if (out != null) { out.write(b, off, len); } else { final Ruby runtime = io.getRuntime(); writeAdapter.call(runtime.getCurrentContext(), io, io, RubyString.newStringLight(runtime, new ByteList(b, off, len, encoding, false))); } }
protected int write(CallSite write, ByteBuffer src) throws IOException { ByteList buffer = new ByteList(src.array(), src.position(), src.remaining(), false); IRubyObject written = write.call(io.getRuntime().getCurrentContext(), io, io, RubyString.newStringLight(io.getRuntime(), buffer)); return (int)written.convertToInteger().getLongValue(); }
protected int write(CallSite write, ByteBuffer src) throws IOException { ByteList buffer = new ByteList(src.array(), src.position(), src.remaining(), false); IRubyObject written = write.call(io.getRuntime().getCurrentContext(), io, io, RubyString.newStringLight(io.getRuntime(), buffer)); return (int)written.convertToInteger().getLongValue(); }
@Override public void write(final int bite) throws IOException { if (out != null) { out.write(bite); } else { writeAdapter.call(io.getRuntime().getCurrentContext(), io, io, RubyString.newStringLight(io.getRuntime(), new ByteList(new byte[]{(byte)bite}, encoding, false))); } }
@Override public void write(final byte[] b,final int off, final int len) throws IOException { if (out != null) { out.write(b, off, len); } else { writeAdapter.call(io.getRuntime().getCurrentContext(), io, io, RubyString.newStringLight(io.getRuntime(), new ByteList(b, off, len, encoding, false))); } }
@Override public void write(final byte[] b,final int off, final int len) throws IOException { if (out != null) { out.write(b, off, len); } else { writeAdapter.call(io.getRuntime().getCurrentContext(), io, io, RubyString.newStringLight(io.getRuntime(), new ByteList(b, off, len, encoding, false))); } }
/** inspect_hash * */ private IRubyObject inspectHash(final ThreadContext context) { final RubyString str = RubyString.newStringLight(context.runtime, DEFAULT_INSPECT_STR_SIZE, USASCIIEncoding.INSTANCE); str.infectBy(this); str.cat((byte)'{'); visitAll(context, InspectVisitor, str); str.cat((byte)'}'); return str; }
/** inspect_hash * */ private IRubyObject inspectHash(final ThreadContext context) { final RubyString str = RubyString.newStringLight(context.runtime, DEFAULT_INSPECT_STR_SIZE, USASCIIEncoding.INSTANCE); str.infectBy(this); str.cat((byte)'{'); visitAll(context, InspectVisitor, str); str.cat((byte)'}'); return str; }
private RubyString inspectEmpty(final Ruby runtime) { RubyString str = RubyString.newStringLight(runtime, 16, USASCIIEncoding.INSTANCE); inspectPrefix(str, getMetaClass()); str.cat('{').cat('}').cat('>'); // "#<Set: {}>" return str; }
@JRubyMethod public static IRubyObject to_s(ThreadContext context, IRubyObject self) { final Encoding ascii8bit = context.runtime.getEncodingService().getAscii8bitEncoding(); // All bytes can be considered raw strings and forced to particular codings if not 8bitascii ByteList bytes = new ByteList((byte[]) ((ArrayJavaProxy) self).getObject(), ascii8bit); return RubyString.newStringLight(context.runtime, bytes); }
private RubyString inspectEmpty(final Ruby runtime) { RubyString str = RubyString.newStringLight(runtime, 16, USASCIIEncoding.INSTANCE); inspectPrefix(str, getMetaClass()); str.cat('{').cat('}').cat('>'); // "#<Set: {}>" return str; }
private RubyString inspectRecurse(final Ruby runtime) { RubyString str = RubyString.newStringLight(runtime, 20, USASCIIEncoding.INSTANCE); inspectPrefix(str, getMetaClass()); str.cat('{').cat(RECURSIVE_BYTES).cat('}').cat('>'); // "#<Set: {...}>" return str; }
private RubyString inspectRecurse(final Ruby runtime) { RubyString str = RubyString.newStringLight(runtime, 20, USASCIIEncoding.INSTANCE); inspectPrefix(str, getMetaClass()); str.cat('{').cat(RECURSIVE_BYTES).cat('}').cat('>'); // "#<Set: {...}>" return str; }