zdavatz / spreadsheet

The Ruby Spreadsheet by ywesee GmbH
http://spreadsheet.ch
GNU General Public License v3.0
1.13k stars 240 forks source link

Add ability to chain methods to `Worksheet#each` #228

Closed spacepotato closed 5 years ago

spacepotato commented 5 years ago

Hey team,

Have been enjoying using this gem in my own projects - nice work!

One thing I've found to be limiting is the inability to treat Worksheet#each as you would Enumerable#each. For example you are unable to use worksheet.each(1).with_index.

This PR adds in that functionality by returning an enumerable object when no block is provided immediately to each.

For example you can now do: worksheet.each(1).with_index do |row, index|

It also respects the previous syntax and still allows: worksheet.each(1) do |row|

I've written specs for both cases.

This is my first open source contribution so let me know if anything needs to be changed!

zdavatz commented 5 years ago

Thank you, merged, and 1.2.0 released.