Project

enumex

0.0
No commit activity in last 3 years
No release in over 3 years
Enumex is a utility to attach preprocessing and postprocessing to Enumerator.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Enumex

Enumex is a utility to attach preprocessing and postprocessing to Enumerator.

Usage

using Enumex

extension = enumex.pre_action.every_time { print "- " }
extension.post_action.every_once(3).times { puts "sleep" }
extension.attach_to((1..10).each) do |n|
  puts n
end

# - 1
# - 2
# - 3
# sleep
# - 4
# - 5
# - 6
# sleep
# - 7
# - 8
# - 9
# sleep
# - 10
# => 1..10
using Enumex

enumex((1..10).each) {|n|
  puts "- #{n}"
}.post_action.every_once(3).times {
  puts "sleep"
}
using Enumex

enumex.post_action.every_once(3).times {
  print "Fizz"
}.every_once(5).times {
  print "Buzz"
}.every_time {
  print "\n"
}.attach_to((1..100).each) do |n|
  print "#{n}: "
end