Package org.jruby.RubyEnumerator

Examples of org.jruby.RubyEnumerator.SizeFn


            i = i.callMethod(context, "+", one);
        }
    }

    private static SizeFn uptoSize(final ThreadContext context, final IRubyObject from, final IRubyObject to) {
        return new SizeFn() {
            @Override
            public IRubyObject size(IRubyObject[] args) {
                return intervalStepSize(context, from, to, RubyFixnum.one(context.runtime), false);
            }
        };
View Full Code Here


            i = i.callMethod(context, "-", one);
        }
    }

    private static SizeFn downToSize(final ThreadContext context, final IRubyObject from, final IRubyObject to) {
        return new SizeFn() {
            @Override
            public IRubyObject size(IRubyObject[] args) {
                return intervalStepSize(context, from, to, RubyFixnum.newFixnum(context.runtime, -1), false);
            }
        };
View Full Code Here

        }
    }

    protected SizeFn timesSizeFn(final Ruby runtime) {
        final RubyInteger self = this;
        return new SizeFn() {
            @Override
            public IRubyObject size(IRubyObject[] args) {
                RubyFixnum zero = RubyFixnum.zero(runtime);
                if ((self instanceof RubyFixnum && getLongValue() < 0)
                        || self.callMethod("<", zero).isTrue()) {
View Full Code Here

        }
        return nil;
    }

    private static SizeFn loopSizeFn(final ThreadContext context) {
        return new SizeFn() {
            @Override
            public IRubyObject size(IRubyObject[] args) {
                return RubyFloat.newFloat(context.runtime, RubyFloat.INFINITY);
            }
        };
View Full Code Here

    }
   
    @JRubyMethod(name = {"to_enum", "enum_for"}, optional = 1, rest = true)
    public static IRubyObject obj_to_enum(final ThreadContext context, IRubyObject self, IRubyObject[] args, final Block block) {
        String method = "each";
        SizeFn sizeFn = null;

        if (args.length > 0) {
            method = args[0].asJavaString();
            args = Arrays.copyOfRange(args, 1, args.length);
        }

        if (block.isGiven()) {
            sizeFn = new SizeFn() {
                @Override
                public IRubyObject size(IRubyObject[] args) {
                    return block.call(context, args);
                }
            };
View Full Code Here

        return array;
    }

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

        return getRuntime().newFixnum(value.getRealSize());
    }

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

        return enumerateChars(context, "chars", block, true);
    }

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

            return str;
    }

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

        return runtime.getNil();
    }

    private static SizeFn cycleSizeFn(final ThreadContext context, final IRubyObject self) {
        return new SizeFn() {
            @Override
            public IRubyObject size(IRubyObject[] args) {
                Ruby runtime = context.runtime;
                IRubyObject n = runtime.getNil();
                IRubyObject size = enumSizeFn(context, self).size(args);
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.