@JRubyMethod(name = "method_missing", rest = true) public IRubyObject methodMissing(ThreadContext context, IRubyObject[] args) { if (args.length == 1) { RubyDescriptor rubyDescriptor = (RubyDescriptor) getDescriptor(context, metaClass); IRubyObject oneofDescriptor = rubyDescriptor.lookupOneof(context, args[0]); if (oneofDescriptor.isNil()) { if (!hasField(args[0])) { return Helpers.invokeSuper(context, this, metaClass, "method_missing", args, Block.NULL_BLOCK); } return index(context, args[0]); } RubyOneofDescriptor rubyOneofDescriptor = (RubyOneofDescriptor) oneofDescriptor; Descriptors.FieldDescriptor fieldDescriptor = oneofCases.get(rubyOneofDescriptor.getOneofDescriptor()); if (fieldDescriptor == null) return context.runtime.getNil(); return context.runtime.newSymbol(fieldDescriptor.getName()); } else { // fieldName is RubySymbol RubyString field = args[0].asString(); RubyString equalSign = context.runtime.newString(Utils.EQUAL_SIGN); if (field.end_with_p(context, equalSign).isTrue()) { field.chomp_bang(context, equalSign); } if (!hasField(field)) { return Helpers.invokeSuper(context, this, metaClass, "method_missing", args, Block.NULL_BLOCK); } return indexSet(context, field, args[1]); } }
/** rb_str_chop * */ @JRubyMethod(name = "chomp", compat = RUBY1_8) public RubyString chomp(ThreadContext context) { RubyString str = strDup(context.runtime); str.chomp_bang(context); return str; }
@JRubyMethod(name = "chomp!", module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE, compat = RUBY1_8) public static IRubyObject chomp_bang(ThreadContext context, IRubyObject recv, IRubyObject arg0) { return getLastlineString(context, context.runtime).chomp_bang(context, arg0); }
@JRubyMethod(name = "chomp", compat = RUBY1_8) public RubyString chomp(ThreadContext context, IRubyObject arg0) { RubyString str = strDup(context.runtime); str.chomp_bang(context, arg0); return str; }
@JRubyMethod(name = "chomp", compat = RUBY1_8) public RubyString chomp(ThreadContext context, IRubyObject arg0) { RubyString str = strDup(context.runtime); str.chomp_bang(context, arg0); return str; }
@JRubyMethod(name = "chomp!", module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE, compat = RUBY1_8) public static IRubyObject chomp_bang(ThreadContext context, IRubyObject recv) { return getLastlineString(context, context.runtime).chomp_bang(context); }
@JRubyMethod(name = "chomp!", module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE, compat = RUBY1_8) public static IRubyObject chomp_bang(ThreadContext context, IRubyObject recv, IRubyObject arg0) { return getLastlineString(context, context.runtime).chomp_bang(context, arg0); }
/** rb_str_chop * */ @JRubyMethod(name = "chomp", compat = RUBY1_8) public RubyString chomp(ThreadContext context) { RubyString str = strDup(context.runtime); str.chomp_bang(context); return str; }
@JRubyMethod(name = "chomp!", module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE, compat = RUBY1_8) public static IRubyObject chomp_bang(ThreadContext context, IRubyObject recv) { return getLastlineString(context, context.runtime).chomp_bang(context); }
@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE, compat = RUBY1_8) public static IRubyObject chomp(ThreadContext context, IRubyObject recv, IRubyObject arg0) { RubyString str = getLastlineString(context, context.runtime); RubyString dup = (RubyString) str.dup(); if (dup.chomp_bang(context, arg0).isNil()) { return str; } context.setLastLine(dup); return dup; }
@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE, compat = RUBY1_8) public static IRubyObject chomp(ThreadContext context, IRubyObject recv) { RubyString str = getLastlineString(context, context.runtime); RubyString dup = (RubyString) str.dup(); if (dup.chomp_bang(context).isNil()) { return str; } context.setLastLine(dup); return dup; }
@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE, compat = RUBY1_8) public static IRubyObject chomp(ThreadContext context, IRubyObject recv) { RubyString str = getLastlineString(context, context.runtime); RubyString dup = (RubyString) str.dup(); if (dup.chomp_bang(context).isNil()) { return str; } context.setLastLine(dup); return dup; }
@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE, compat = RUBY1_8) public static IRubyObject chomp(ThreadContext context, IRubyObject recv, IRubyObject arg0) { RubyString str = getLastlineString(context, context.runtime); RubyString dup = (RubyString) str.dup(); if (dup.chomp_bang(context, arg0).isNil()) { return str; } context.setLastLine(dup); return dup; }
/** * getline using logic of gets. If limit is -1 then read unlimited amount. * mri: rb_io_getline_1 (mostly) */ private IRubyObject getlineImpl(ThreadContext context, IRubyObject rs, final int limit, final boolean chomp) { Ruby runtime = context.runtime; final OpenFile fptr = getOpenFileChecked(); final boolean locked = fptr.lock(); try { fptr.checkCharReadable(context); if (limit == 0) { return RubyString.newEmptyString(runtime, fptr.readEncoding(runtime)); } RubyString str = null; Encoding enc; if (rs == context.nil && limit < 0) { str = (RubyString) fptr.readAll(context, 0, context.nil); if (str.size() == 0) return context.nil; if (chomp) str.chomp_bang(context, runtime.getGlobalVariables().getDefaultSeparator()); } else if (rs == runtime.getGlobalVariables().getDefaultSeparator() && limit < 0 && !fptr.needsReadConversion() && (enc = fptr.readEncoding(runtime)).isAsciiCompatible()) { fptr.NEED_NEWLINE_DECORATOR_ON_READ_CHECK(); return fptr.getlineFast(context, enc, this, chomp); } return getlineImplSlowPart(context, fptr, str, rs, limit, chomp); } finally { if (locked) fptr.unlock(); } }
/** * getline using logic of gets. If limit is -1 then read unlimited amount. * mri: rb_io_getline_1 (mostly) */ private IRubyObject getlineImpl(ThreadContext context, IRubyObject rs, final int limit, final boolean chomp) { Ruby runtime = context.runtime; final OpenFile fptr = getOpenFileChecked(); final boolean locked = fptr.lock(); try { fptr.checkCharReadable(context); if (limit == 0) { return RubyString.newEmptyString(runtime, fptr.readEncoding(runtime)); } RubyString str = null; Encoding enc; if (rs == context.nil && limit < 0) { str = (RubyString) fptr.readAll(context, 0, context.nil); if (str.size() == 0) return context.nil; if (chomp) str.chomp_bang(context, runtime.getGlobalVariables().getDefaultSeparator()); } else if (rs == runtime.getGlobalVariables().getDefaultSeparator() && limit < 0 && !fptr.needsReadConversion() && (enc = fptr.readEncoding(runtime)).isAsciiCompatible()) { fptr.NEED_NEWLINE_DECORATOR_ON_READ_CHECK(); return fptr.getlineFast(context, enc, this, chomp); } return getlineImplSlowPart(context, fptr, str, rs, limit, chomp); } finally { if (locked) fptr.unlock(); } }