Module: XDry::EnumerableAdditions
- Defined in:
- lib/xdry/support/enumerable_additions.rb
Instance Method Summary collapse
Instance Method Details
#prefix_while ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/xdry/support/enumerable_additions.rb', line 6 def prefix_while result = [] each do |item| if yield(item) result << item else break end end return result end |
#suffix_while ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/xdry/support/enumerable_additions.rb', line 18 def suffix_while result = [] reverse_each do |item| if yield(item) result << item else break end end return result.reverse! end |