IronRuby.Runtime.BlockParam.Yield C# (CSharp) Method

Yield() public method

public Yield ( object &blockResult ) : bool
blockResult object
return bool
        public bool Yield(out object blockResult) {
            return BlockJumped(blockResult = RubyOps.Yield0(null, Self, this));
        }

Same methods

BlockParam::Yield ( object arg1, object &blockResult ) : bool
BlockParam::Yield ( object arg1, object arg2, object &blockResult ) : bool
BlockParam::Yield ( object arg1, object arg2, object arg3, object &blockResult ) : bool
BlockParam::Yield ( object arg1, object arg2, object arg3, object arg4, object &blockResult ) : bool

Usage Example

Example #1
1
        public static object EachObject(BlockParam block, RubyModule/*!*/ self, [NotNull]RubyClass/*!*/ theClass) {
            Type classType = theClass.GetType();
            bool isClass = (classType == typeof(RubyClass));
            if (!isClass && classType != typeof(RubyModule)) {
                throw new NotSupportedException("each_object only supported for objects of type Class or Module");
            }
            if (block == null) {
                throw RubyExceptions.NoBlockGiven();
            }

            Dictionary<RubyModule, object> visited = new Dictionary<RubyModule, object>();
            Stack<RubyModule> modules = new Stack<RubyModule>();
            modules.Push(theClass.Context.ObjectClass);
            while (modules.Count > 0) {
                RubyModule next = modules.Pop();
                RubyClass asClass = next as RubyClass;

                if (!isClass || asClass != null) {
                    object result;
                    if (block.Yield(next, out result)) {
                        return result;
                    }
                }
                next.EnumerateConstants(delegate(RubyModule module, string name, object value) {
                    RubyModule constAsModule = (value as RubyModule);
                    if (constAsModule != null && !visited.ContainsKey(constAsModule)) {
                        modules.Push(constAsModule);
                        visited[module] = null;
                    }
                    return false;
                });
            }
            return visited.Count;
        }
All Usage Examples Of IronRuby.Runtime.BlockParam::Yield