@@ -132,16 +132,20 @@ def initialize(obj=NONE, meth=:each, *args, **kwd, &block)
|
132 | 132 | @stop_exc = false |
133 | 133 | end |
134 | 134 | |
135 | | -attr_accessor :obj, :meth, :args, :kwd |
136 | | -attr_reader :fib |
137 | | - |
138 | 135 | def initialize_copy(obj) |
139 | 136 | raise TypeError, "can't copy type #{obj.class}" unless obj.kind_of? Enumerator |
140 | | -raise TypeError, "can't copy execution context" if obj.fib |
141 | | -@obj = obj.obj |
142 | | -@meth = obj.meth |
143 | | -@args = obj.args |
144 | | -@kwd = obj.kwd |
| 137 | +raise TypeError, "can't copy execution context" if obj.instance_eval{@fib} |
| 138 | +meth = args = kwd = fib = nil |
| 139 | +obj.instance_eval { |
| 140 | +obj = @obj |
| 141 | +meth = @meth |
| 142 | +args = @args |
| 143 | +kwd = @kwd |
| 144 | +} |
| 145 | +@obj = obj |
| 146 | +@meth = meth |
| 147 | +@args = args |
| 148 | +@kwd = kwd |
145 | 149 | @fib = nil |
146 | 150 | @lookahead = nil |
147 | 151 | @feedvalue = nil |
@@ -274,14 +278,14 @@ def each(*argv, &block)
|
274 | 278 | obj = self |
275 | 279 | if 0 < argv.length |
276 | 280 | obj = self.dup |
277 | | -args = obj.args |
| 281 | +args = obj.instance_eval{@args} |
278 | 282 | if !args.empty? |
279 | 283 | args = args.dup |
280 | 284 | args.concat argv |
281 | 285 | else |
282 | 286 | args = argv.dup |
283 | 287 | end |
284 | | -obj.args = args |
| 288 | +obj.instance_eval{@args = args} |
285 | 289 | end |
286 | 290 | return obj unless block |
287 | 291 | enumerator_block_call(&block) |
|