Package org.jruby.runtime.builtin

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


                    methodIndex = MethodIndex.OP_LE;
                }
                IRubyObject beg = begin;
                while (beg.callMethod(context, methodIndex, method, end).isTrue()) {
                    block.yield(context, beg);
                    beg = beg.callMethod(context, MethodIndex.OP_PLUS, "+", step);
                }
            } else {
                if (unit == 0) throw runtime.newArgumentError("step can't be 0");
                if (!begin.respondsTo("succ")) throw runtime.newTypeError(
                        "can't iterate from " + begin.getMetaClass().getName());
View Full Code Here


        StringBuilder buffer = new StringBuilder(100);

        buffer.append(fileName).append(':').append(lineNumber + 1).append(' ');
        buffer.append("warning: ").append(message).append('\n');
        IRubyObject errorStream = runtime.getGlobalVariables().get("$stderr");
        errorStream.callMethod(runtime.getCurrentContext(), "write", runtime.newString(buffer.toString()));
    }

    public boolean isVerbose() {
        return runtime.getVerbose().isTrue();
    }
View Full Code Here

        IRubyObject z = callMethod(context, "%", dividend);
        IRubyObject x = this;
        RubyFixnum zero = RubyFixnum.zero(getRuntime());

        if (!equalInternal(context, z, zero) &&
                ((x.callMethod(context, MethodIndex.OP_LT, "<", zero).isTrue() &&
                dividend.callMethod(context, MethodIndex.OP_GT, ">", zero).isTrue()) ||
                (x.callMethod(context, MethodIndex.OP_GT, ">", zero).isTrue() &&
                dividend.callMethod(context, MethodIndex.OP_LT, "<", zero).isTrue()))) {
            return z.callMethod(context, MethodIndex.OP_MINUS, "-", dividend);
        } else {
View Full Code Here

        RubyFixnum zero = RubyFixnum.zero(getRuntime());

        if (!equalInternal(context, z, zero) &&
                ((x.callMethod(context, MethodIndex.OP_LT, "<", zero).isTrue() &&
                dividend.callMethod(context, MethodIndex.OP_GT, ">", zero).isTrue()) ||
                (x.callMethod(context, MethodIndex.OP_GT, ">", zero).isTrue() &&
                dividend.callMethod(context, MethodIndex.OP_LT, "<", zero).isTrue()))) {
            return z.callMethod(context, MethodIndex.OP_MINUS, "-", dividend);
        } else {
            return z;
        }
View Full Code Here

                if (minMemo == null) {
                    minMemo = maxMemo = v;
                    result[0] = result[1] = arg;
                } else {
                    if (RubyComparable.cmpint(ctx, v.callMethod(ctx,
                        MethodIndex.OP_SPACESHIP, "<=>", minMemo), v, minMemo) < 0) {
                        minMemo = v;
                        result[0] = arg;
                    }
                    if (RubyComparable.cmpint(ctx, v.callMethod(ctx,
View Full Code Here

                    if (RubyComparable.cmpint(ctx, v.callMethod(ctx,
                        MethodIndex.OP_SPACESHIP, "<=>", minMemo), v, minMemo) < 0) {
                        minMemo = v;
                        result[0] = arg;
                    }
                    if (RubyComparable.cmpint(ctx, v.callMethod(ctx,
                            MethodIndex.OP_SPACESHIP, "<=>", maxMemo), v, maxMemo) > 0) {
                        maxMemo = v;
                        result[1] = arg;
                    }
                }
View Full Code Here

            IRubyObject memo = null;
            public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
                checkContext(localContext, ctx, "max_by");
                IRubyObject v = block.yield(ctx, largs[0]);

                if (memo == null || RubyComparable.cmpint(ctx, v.callMethod(ctx,
                        MethodIndex.OP_SPACESHIP, "<=>", memo), v, memo) > 0) {
                    memo = v;
                    result[0] = largs[0];
                }
                return runtime.getNil();
View Full Code Here

            IRubyObject memo = null;
            public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
                checkContext(localContext, ctx, "min_by");
                IRubyObject v = block.yield(ctx, largs[0]);

                if (memo == null || RubyComparable.cmpint(ctx, v.callMethod(ctx,
                        MethodIndex.OP_SPACESHIP, "<=>", memo), v, memo) < 0) {
                    memo = v;
                    result[0] = largs[0];
                }
                return runtime.getNil();
View Full Code Here

                    IRubyObject arg = largs[0];
                    synchronized (result) {
                        if (result[0] == null) {
                            result[0] = result[1] = arg;
                        } else {
                            if (RubyComparable.cmpint(ctx, arg.callMethod(ctx, "<=>", result[0]), arg, result[0]) < 0) {
                                result[0] = arg;
                            }

                            if (RubyComparable.cmpint(ctx, arg.callMethod(ctx, "<=>", result[1]), arg, result[1]) > 0) {
                                result[1] = arg;
View Full Code Here

                        } else {
                            if (RubyComparable.cmpint(ctx, arg.callMethod(ctx, "<=>", result[0]), arg, result[0]) < 0) {
                                result[0] = arg;
                            }

                            if (RubyComparable.cmpint(ctx, arg.callMethod(ctx, "<=>", result[1]), arg, result[1]) > 0) {
                                result[1] = arg;
                            }
                        }
                    }
                    return runtime.getNil();
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.