Skip to content

Commit 9e58074

Browse files
committed
Refactor: Change Refinement To Understand That each Passes One Item
Why This Change Is Necessary ======================================================================== `each` does not deal with multiple items, it always yields [a single element][2] and so we can refrain from using `args` there. What These Changes Do To Address the Issue ======================================================================== Switch from `*args` to `item`. Caveats ------------------------------------------------------------------------ We are still going to pass `*yielded_args` to the `yield` because in the next commit we will pass a second argument to that `yield` call. Side Effects Caused By This Change ======================================================================== None expected. ------------------------------------------------------------------------ **Relevant URLs:** * [Ticket Link][1] * [Ruby Doc For `each`][2] ------------------------------------------------------------------------ [1]: #185 [2]: https://ruby-doc.org/2.7.6/Enumerator.html#method-i-each
1 parent d4a093c commit 9e58074

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/ruby-progressbar/refinements/enumerator.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ module Enumerator
55
def with_progressbar(options = {}, &block)
66
progress_bar = ProgressBar.create(options.merge(:starting_at => 0, :total => size))
77

8-
each do |*yielded_args|
8+
each do |item|
99
progress_bar.increment
1010

1111
next unless block
1212

13+
yielded_args = []
14+
yielded_args << item
15+
1316
yield(*yielded_args)
1417
end
1518
end

0 commit comments

Comments
 (0)