Module: Enumerable
- Defined in:
- lib/lookaround-enumerable.rb
Aliases collapse
-
#collect_with_prev ⇒ Object
Aliases for each_with_prev(*args).map.
-
#collect_with_window ⇒ Object
Aliases for each_with_window(*args).map.
-
#find_all_with_prev ⇒ Object
Aliases for select.each_with_prev(*args).
-
#find_all_with_window ⇒ Object
Aliases for select.each_with_window(*args).
-
#inject_with_prev ⇒ Object
Aliases for inject(memo).each_with_prev(*args).
-
#inject_with_window ⇒ Object
Aliases for inject(memo).each_with_window(*args).
-
#map_with_prev ⇒ Object
Aliases for each_with_prev(*args).map.
-
#map_with_window ⇒ Object
Aliases for each_with_window(*args).map.
-
#pcollect ⇒ Object
Aliases for each_with_prev(*args).map.
-
#pfind_all ⇒ Object
Aliases for select.each_with_prev(*args).
-
#pinject ⇒ Object
Aliases for inject(memo).each_with_prev(*args).
-
#pmap ⇒ Object
Aliases for each_with_prev(*args).map.
-
#preduce ⇒ Object
Aliases for inject(memo).each_with_prev(*args).
-
#pselect ⇒ Object
Aliases for select.each_with_prev(*args).
-
#reduce_with_prev ⇒ Object
Aliases for inject(memo).each_with_prev(*args).
-
#reduce_with_window ⇒ Object
Aliases for inject(memo).each_with_window(*args).
-
#select_with_prev ⇒ Object
Aliases for select.each_with_prev(*args).
-
#select_with_window ⇒ Object
Aliases for select.each_with_window(*args).
-
#wcollect ⇒ Object
Aliases for each_with_window(*args).map.
-
#wfind_all ⇒ Object
Aliases for select.each_with_window(*args).
-
#winject ⇒ Object
Aliases for inject(memo).each_with_window(*args).
-
#wmap ⇒ Object
Aliases for each_with_window(*args).map.
-
#wreduce ⇒ Object
Aliases for inject(memo).each_with_window(*args).
-
#wselect ⇒ Object
Aliases for select.each_with_window(*args).
Instance Method Summary collapse
-
#each_with_prev ⇒ Object
Calls block with two (or more, depending on the expand) arguments: the item and the values at earlier indexes.
-
#each_with_window ⇒ Object
Calls block with three (or more, depending on the expand) arguments: the item and the values at earlier and later indexes.
Instance Method Details
#collect_with_prev(*args) {|(*args), (*previous)| ... } ⇒ Object #collect_with_prev(*args) ⇒ Enumerator
Aliases for each_with_prev(*args).map
|
|
# File 'lib/lookaround-enumerable.rb', line 354
|
#collect_with_window(*args) {|(*args), (*previous)| ... } ⇒ Object #collect_with_window(*args) ⇒ Enumerator
Aliases for each_with_window(*args).map
|
|
# File 'lib/lookaround-enumerable.rb', line 550
|
#each_with_prev(size = 1, crop: false, trim: false, filler: nil, expand: :single) {|(*args), (*previous)| ... } ⇒ Enumerable #each_with_prev(size = 1, crop: false, trim: false, filler: nil, expand: :single) ⇒ Enumerator
Calls block with two (or more, depending on the expand) arguments: the item and the values at earlier indexes.
If no block is given, an enumerator is returned instead.
expand:-
(Symbol) Valid options are:
:none-
Never expands, block always takes two arguments, each an array
(1..3).each_with_prev(expand: :none) {|(current), (prev)| } (1..3).each_with_object({}).each_with_prev(2, expand: :none) {|(current, obj), (prev, prev2)| }:single-
(default) Expands if only one element, block always takes two arguments, each an array or an object
(1..3).each_with_prev(expand: :single) {|current, prev| } (1..3).each_with_prev(2, expand: :single) {|current, (prev, prev2)| } (1..3).each_with_object({}).each_with_prev(2, expand: :single) {|(current, obj), (prev, prev2)| }:all-
Expands all sides, block takes two or more arguments, each an object
(1..3).each_with_prev(expand: :all) {|current, prev| } (1..3).each_with_prev(2, expand: :all) {|current, prev, prev2| } (1..3).each_with_object({}).each_with_prev(2, expand: :all) {|current, obj, prev, prev2| }
|
|
# File 'lib/lookaround-enumerable.rb', line 229
|
#each_with_window(view = -1..1, crop: false, trim: false, filler: nil, expand: :single) {|(*left), (*args), (*right)| ... } ⇒ Enumerable #each_with_window(size = -1..1, crop: false, trim: false, filler: nil, expand: :single) ⇒ Enumerator
Calls block with three (or more, depending on the expand) arguments: the item and the values at earlier and later indexes.
If no block is given, an enumerator is returned instead.
Important note: each_with_window is executed in a disjunct manner from the parent iterator. This can cause issues when chained with other Enumerators. Please use the built in helpers.
|
|
# File 'lib/lookaround-enumerable.rb', line 303
|
#find_all_with_prev(*args) {|(*args), (*previous)| ... } ⇒ Object #find_all_with_prev(*args) ⇒ Enumerator
Aliases for select.each_with_prev(*args)
|
|
# File 'lib/lookaround-enumerable.rb', line 420
|
#find_all_with_window(*args) {|(*args), (*previous)| ... } ⇒ Object #find_all_with_window(*args) ⇒ Enumerator
Aliases for select.each_with_window(*args)
|
|
# File 'lib/lookaround-enumerable.rb', line 616
|
#inject_with_prev(memo = first, *args) {|(*args), (*previous)| ... } ⇒ Object #inject_with_prev(memo = first, *args) ⇒ Enumerator
Aliases for inject(memo).each_with_prev(*args)
|
|
# File 'lib/lookaround-enumerable.rb', line 469
|
#inject_with_window(memo = first, *args) {|(*args), (*previous)| ... } ⇒ Object #inject_with_window(memo = first, *args) ⇒ Enumerator
Aliases for inject(memo).each_with_window(*args)
|
|
# File 'lib/lookaround-enumerable.rb', line 665
|
#map_with_prev(*args) {|(*args), (*previous)| ... } ⇒ Object #map_with_prev(*args) ⇒ Enumerator
Aliases for each_with_prev(*args).map
|
|
# File 'lib/lookaround-enumerable.rb', line 338
|
#map_with_window(*args) {|(*args), (*previous)| ... } ⇒ Object #map_with_window(*args) ⇒ Enumerator
Aliases for each_with_window(*args).map
|
|
# File 'lib/lookaround-enumerable.rb', line 534
|
#pcollect(*args) {|(*args), (*previous)| ... } ⇒ Object #pcollect(*args) ⇒ Enumerator
Aliases for each_with_prev(*args).map
|
|
# File 'lib/lookaround-enumerable.rb', line 386
|
#pfind_all(*args) {|(*args), (*previous)| ... } ⇒ Object #pfind_all(*args) ⇒ Enumerator
Aliases for select.each_with_prev(*args)
|
|
# File 'lib/lookaround-enumerable.rb', line 452
|
#pinject(memo = first, *args) {|(*args), (*previous)| ... } ⇒ Object #pinject(memo = first, *args) ⇒ Enumerator
Aliases for inject(memo).each_with_prev(*args)
|
|
# File 'lib/lookaround-enumerable.rb', line 501
|
#pmap(*args) {|(*args), (*previous)| ... } ⇒ Object #pmap(*args) ⇒ Enumerator
Aliases for each_with_prev(*args).map
|
|
# File 'lib/lookaround-enumerable.rb', line 370
|
#preduce(memo = first, *args) {|(*args), (*previous)| ... } ⇒ Object #preduce(memo = first, *args) ⇒ Enumerator
Aliases for inject(memo).each_with_prev(*args)
|
|
# File 'lib/lookaround-enumerable.rb', line 517
|
#pselect(*args) {|(*args), (*previous)| ... } ⇒ Object #pselect(*args) ⇒ Enumerator
Aliases for select.each_with_prev(*args)
|
|
# File 'lib/lookaround-enumerable.rb', line 436
|
#reduce_with_prev(memo = first, *args) {|(*args), (*previous)| ... } ⇒ Object #reduce_with_prev(memo = first, *args) ⇒ Enumerator
Aliases for inject(memo).each_with_prev(*args)
|
|
# File 'lib/lookaround-enumerable.rb', line 485
|
#reduce_with_window(memo = first, *args) {|(*args), (*previous)| ... } ⇒ Object #reduce_with_window(memo = first, *args) ⇒ Enumerator
Aliases for inject(memo).each_with_window(*args)
|
|
# File 'lib/lookaround-enumerable.rb', line 681
|
#select_with_prev(*args) {|(*args), (*previous)| ... } ⇒ Object #select_with_prev(*args) ⇒ Enumerator
Aliases for select.each_with_prev(*args)
|
|
# File 'lib/lookaround-enumerable.rb', line 404
|
#select_with_window(*args) {|(*args), (*previous)| ... } ⇒ Object #select_with_window(*args) ⇒ Enumerator
Aliases for select.each_with_window(*args)
|
|
# File 'lib/lookaround-enumerable.rb', line 600
|
#wcollect(*args) {|(*args), (*previous)| ... } ⇒ Object #wcollect(*args) ⇒ Enumerator
Aliases for each_with_window(*args).map
|
|
# File 'lib/lookaround-enumerable.rb', line 582
|
#wfind_all(*args) {|(*args), (*previous)| ... } ⇒ Object #wfind_all(*args) ⇒ Enumerator
Aliases for select.each_with_window(*args)
|
|
# File 'lib/lookaround-enumerable.rb', line 648
|
#winject(memo = first, *args) {|(*args), (*previous)| ... } ⇒ Object #winject(memo = first, *args) ⇒ Enumerator
Aliases for inject(memo).each_with_window(*args)
|
|
# File 'lib/lookaround-enumerable.rb', line 697
|
#wmap(*args) {|(*args), (*previous)| ... } ⇒ Object #wmap(*args) ⇒ Enumerator
Aliases for each_with_window(*args).map
|
|
# File 'lib/lookaround-enumerable.rb', line 566
|
#wreduce(memo = first, *args) {|(*args), (*previous)| ... } ⇒ Object #wreduce(memo = first, *args) ⇒ Enumerator
Aliases for inject(memo).each_with_window(*args)
|
|
# File 'lib/lookaround-enumerable.rb', line 713
|
#wselect(*args) {|(*args), (*previous)| ... } ⇒ Object #wselect(*args) ⇒ Enumerator
Aliases for select.each_with_window(*args)
|
|
# File 'lib/lookaround-enumerable.rb', line 632
|