each_object

each_object

ri

 ------------------------------------------------ ObjectSpace#each_object
      ObjectSpace.each_object([module]) {|obj| ... } => fixnum
 ------------------------------------------------------------------------
      Calls the block once for each living, nonimmediate object in this
      Ruby process. If _module_ is specified, calls the block for only
      those classes or modules that match (or are a subclass of)
      _module_. Returns the number of objects found. Immediate objects
      ( Fixnum s,  Symbol s  true ,  false , and  nil ) are never
      returned. In the example below,  each_object  returns both the
      numbers we defined and several constants defined in the  Math 
      module.
 
         a = 102.7
         b = 95       # Won't be returned
         c = 12345678987654321
         count = ObjectSpace.each_object(Numeric) {|x| p x }
         puts "Total count: #{count}"
 
      _produces:_
 
         12345678987654321
         102.7
         2.71828182845905
         3.14159265358979
         2.22044604925031e-16
         1.7976931348623157e 308
         2.2250738585072e-308
         Total count: 7
 

refe

 ObjectSpace.each_object
 --- ObjectSpace.each_object([class_or_module]) {|object| ...}
 
     class_or_module と kind_of? の関係にある全ての
     オブジェクトに対して繰り返します。引数が省略された時には全てのオブ
     ジェクトに対して繰り返します。
 
     class_or_module に FixnumSymbol を指定しても
     何も繰り返しません。
 
     繰り返した数を返します。