@JRubyMethod public IRubyObject byteslice(ThreadContext context, IRubyObject arg1, IRubyObject arg2) { return byteSubstr(context.runtime, RubyNumeric.num2int(arg1), RubyNumeric.num2int(arg2)); }
@JRubyMethod(compat = RUBY1_9) public IRubyObject byteslice(ThreadContext context, IRubyObject arg1, IRubyObject arg2) { return byteSubstr(context.runtime, RubyNumeric.num2int(arg1), RubyNumeric.num2int(arg2)); }
@JRubyMethod public IRubyObject byteslice(ThreadContext context, IRubyObject arg1, IRubyObject arg2) { return byteSubstr(context.runtime, RubyNumeric.num2int(arg1), RubyNumeric.num2int(arg2)); }
@JRubyMethod(compat = RUBY1_9) public IRubyObject byteslice(ThreadContext context, IRubyObject arg1, IRubyObject arg2) { return byteSubstr(context.runtime, RubyNumeric.num2int(arg1), RubyNumeric.num2int(arg2)); }
private IRubyObject byteARef(Ruby runtime, IRubyObject idx) { final int index; if (idx instanceof RubyRange){ int[] begLen = ((RubyRange) idx).begLenInt(getByteList().length(), 0); return begLen == null ? runtime.getNil() : byteSubstr(runtime, begLen[0], begLen[1]); } else if (idx instanceof RubyFixnum) { index = RubyNumeric.fix2int((RubyFixnum)idx); } else { index = RubyNumeric.num2int(idx); } IRubyObject obj = byteSubstr(runtime, index, 1); if (obj.isNil() || ((RubyString)obj).getByteList().length() == 0) return runtime.getNil(); return obj; }
private IRubyObject byteARef(Ruby runtime, IRubyObject idx) { final int index; if (idx instanceof RubyRange){ int[] begLen = ((RubyRange) idx).begLenInt(getByteList().length(), 0); return begLen == null ? runtime.getNil() : byteSubstr(runtime, begLen[0], begLen[1]); } else if (idx instanceof RubyFixnum) { index = RubyNumeric.fix2int((RubyFixnum)idx); } else { index = RubyNumeric.num2int(idx); } IRubyObject obj = byteSubstr(runtime, index, 1); if (obj.isNil() || ((RubyString)obj).getByteList().length() == 0) return runtime.getNil(); return obj; }
private IRubyObject byteARef(Ruby runtime, IRubyObject idx) { final int index; if (idx instanceof RubyRange){ int[] begLen = ((RubyRange) idx).begLenInt(getByteList().length(), 0); return begLen == null ? runtime.getNil() : byteSubstr(runtime, begLen[0], begLen[1]); } else if (idx instanceof RubyFixnum) { index = RubyNumeric.fix2int((RubyFixnum)idx); } else { ThreadContext context = runtime.getCurrentContext(); StringSites sites = sites(context); if (RubyRange.isRangeLike(context, idx, sites.respond_to_begin, sites.respond_to_end)) { RubyRange range = RubyRange.rangeFromRangeLike(context, idx, sites.begin, sites.end, sites.exclude_end); int[] begLen = range.begLenInt(getByteList().length(), 0); return begLen == null ? runtime.getNil() : byteSubstr(runtime, begLen[0], begLen[1]); } else { index = RubyNumeric.num2int(idx); } } IRubyObject obj = byteSubstr(runtime, index, 1); if (obj.isNil() || ((RubyString)obj).getByteList().length() == 0) return runtime.getNil(); return obj; }
private IRubyObject byteARef(Ruby runtime, IRubyObject idx) { final int index; if (idx instanceof RubyRange){ int[] begLen = ((RubyRange) idx).begLenInt(getByteList().length(), 0); return begLen == null ? runtime.getNil() : byteSubstr(runtime, begLen[0], begLen[1]); } else if (idx instanceof RubyFixnum) { index = RubyNumeric.fix2int((RubyFixnum)idx); } else { ThreadContext context = runtime.getCurrentContext(); StringSites sites = sites(context); if (RubyRange.isRangeLike(context, idx, sites.respond_to_begin, sites.respond_to_end)) { RubyRange range = RubyRange.rangeFromRangeLike(context, idx, sites.begin, sites.end, sites.exclude_end); int[] begLen = range.begLenInt(getByteList().length(), 0); return begLen == null ? runtime.getNil() : byteSubstr(runtime, begLen[0], begLen[1]); } else { index = RubyNumeric.num2int(idx); } } IRubyObject obj = byteSubstr(runtime, index, 1); if (obj.isNil() || ((RubyString)obj).getByteList().length() == 0) return runtime.getNil(); return obj; }