Package org.jruby.RubyEnumerator

Examples of org.jruby.RubyEnumerator.SizeFn


    public static IRubyObject each_slice19(ThreadContext context, IRubyObject self, IRubyObject arg, final Block block) {
        return block.isGiven() ? each_slice(context, self, arg, block) : enumeratorizeWithSize(context, self, "each_slice", new IRubyObject[]{arg}, eachSliceSizeFn(context, self));
    }

    private static SizeFn eachSliceSizeFn(final ThreadContext context, final IRubyObject self) {
        return new SizeFn() {
            @Override
            public IRubyObject size(IRubyObject[] args) {
                Ruby runtime = context.runtime;
                assert args != null && args.length > 0 && args[0] instanceof RubyNumeric; // #each_slice ensures arg[0] is numeric
                long sliceSize = ((RubyNumeric) args[0]).getLongValue();
View Full Code Here


    public static IRubyObject each_cons19(ThreadContext context, IRubyObject self, IRubyObject arg, final Block block) {
        return block.isGiven() ? each_cons(context, self, arg, block) : enumeratorizeWithSize(context, self, "each_cons", new IRubyObject[] { arg }, eachConsSizeFn(context, self));
    }

    private static SizeFn eachConsSizeFn(final ThreadContext context, final IRubyObject self) {
        return new SizeFn() {
            @Override
            public IRubyObject size(IRubyObject[] args) {
                Ruby runtime = context.runtime;
                assert args != null && args.length > 0 && args[0] instanceof RubyNumeric; // #each_cons ensures arg[0] is numeric
                long consSize = ((RubyNumeric) args[0]).getLongValue();
View Full Code Here

                        new ChunkedBlockCallback(context.runtime, enumerator), context));
        return enumerator;
    }

    private static SizeFn enumSizeFn(final ThreadContext context, final IRubyObject self) {
        return new SizeFn() {
            @Override
            public IRubyObject size(IRubyObject[] args) {
                return self.checkCallMethod(context, "size");
            }
        };
View Full Code Here

            return (RubyNumeric) result;
        }
    }

    private SizeFn stepSizeFn(final ThreadContext context, final IRubyObject from, final IRubyObject[] args) {
        return new SizeFn() {
            @Override
            public IRubyObject size(IRubyObject[] args) {
                IRubyObject[] scannedArgs = scanStepArgs(context, args);
                return intervalStepSize(context, from, scannedArgs[0], scannedArgs[1], false);
            }
View Full Code Here

        }
    }

    private SizeFn enumSizeFn(final ThreadContext context) {
        final RubyRange self = this;
        return new SizeFn() {
            @Override
            public IRubyObject size(IRubyObject[] args) {
                return self.size(context);
            }
        };
View Full Code Here

        };
    }

    private SizeFn stepSizeFn(final ThreadContext context) {
        final RubyRange self = this;
        return new SizeFn() {
            @Override
            public IRubyObject size(IRubyObject[] args) {
                Ruby runtime = context.runtime;
                IRubyObject begin = self.begin;
                IRubyObject end = self.end;
View Full Code Here

        return getRuntime().newFixnum(realLength);
    }

    private SizeFn enumLengthFn() {
        final RubyArray self = this;
        return new SizeFn() {
            @Override
            public IRubyObject size(IRubyObject[] args) {
                return self.length();
            }
        };
View Full Code Here

        }
        return context.runtime.getNil();
    }

    private SizeFn cycleSizeFn(final ThreadContext context) {
        return new SizeFn() {
            @Override
            public IRubyObject size(IRubyObject[] args) {
                Ruby runtime = context.runtime;
                IRubyObject n = runtime.getNil();
View Full Code Here

        }
    }

    private SizeFn combinationSize(final ThreadContext context) {
        final RubyArray self = this;
        return new SizeFn() {
            @Override
            public IRubyObject size(IRubyObject[] args) {
                long n = self.realLength;
                assert args != null && args.length > 0 && args[0] instanceof RubyNumeric; // #combination ensures arg[0] is numeric
                long k = ((RubyNumeric) args[0]).getLongValue();
View Full Code Here

        return this;
    }

    private SizeFn repeatedCombinationSize(final ThreadContext context) {
        final RubyArray self = this;
        return new SizeFn() {
            @Override
            public IRubyObject size(IRubyObject[] args) {
                long n = self.realLength;
                assert args != null && args.length > 0 && args[0] instanceof RubyNumeric; // #repeated_combination ensures arg[0] is numeric
                long k = ((RubyNumeric) args[0]).getLongValue();
View Full Code Here

TOP

Related Classes of org.jruby.RubyEnumerator.SizeFn

Copyright © 2018 www.massapicom. 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.