Module: Enumerable
- Included in:
- InBetweenEnum, Wood::Nodes::CodeBlock
- Defined in:
- lib/core_ext/enumerable.rb
Defined Under Namespace
Classes: InBetweenEnum
Instance Method Summary collapse
-
#in_between(&block) ⇒ InBetweenEnum
Creates a InBetweenEnum for iteration while calling ‘block` in between.
-
#map_with_index ⇒ Array
Same as #map but passing along the index with each element to a given block.
Instance Method Details
#in_between(&block) ⇒ InBetweenEnum
Creates a InBetweenEnum for iteration while calling ‘block` in between.
28 29 30 |
# File 'lib/core_ext/enumerable.rb', line 28 def in_between(&block) InBetweenEnum.new(self, block) end |
#map_with_index ⇒ Array
Same as #map but passing along the index with each element to a given block.
40 41 42 43 44 45 46 |
# File 'lib/core_ext/enumerable.rb', line 40 def map_with_index arr = [] each_with_index do |x, i| arr << yield(x, i) end arr end |