예제 #1
0
        public static object EachDocument(RubyScope /*!*/ scope, BlockParam block, RubyModule /*!*/ self, object io)
        {
            RubyConstructor rc = MakeConstructor(scope, CheckYamlPort(io));

            if (block == null && rc.CheckData())
            {
                throw RubyExceptions.NoBlockGiven();
            }

            foreach (object obj in rc)
            {
                object result;
                if (block.Yield(obj, out result))
                {
                    return(result);
                }
            }
            return(null);
        }
예제 #2
0
        public static object EachDocument(ConversionStorage <MutableString> /*!*/ toStr, RespondToStorage /*!*/ respondTo,
                                          RubyScope /*!*/ scope, BlockParam block, RubyModule /*!*/ self, object io)
        {
            RubyConstructor rc = MakeConstructor(scope.GlobalScope, GetStream(toStr, respondTo, io));

            if (block == null && rc.CheckData())
            {
                throw RubyExceptions.NoBlockGiven();
            }

            foreach (object obj in rc)
            {
                object result;
                if (block.Yield(obj, out result))
                {
                    return(result);
                }
            }
            return(null);
        }