Chad Remesch bio photo

Chad Remesch

Entrepreneur and software engineer

Email LinkedIn Instagram Github

Filter Chain is a Ruby gem for processing data through a chain of filters in an object oriented style.  It includes a number of filters for simple tasks like compression, serialization, and multiplexing.

It is very common in Ruby to use blocks and functional style programming to manipulate data.  The below example squares each element in an array and then removes the odd values:

[1,2,3,4,5].map { |i| i**2 }.reject { |i| i.odd? }

Such one-liners are an amazing feature of Ruby and very useful on the console.  Unfortunately, they can really start to break down in more complex situations.  This is where Filter Chain can be really useful.

Unlike in the above example, filters in Filter Chain are dedicated classes with a simple API.  This means each filter can easily have it's own state, private helper methods, independent tests, and be reusable.  This is especially true for filters that include buffering, multithreading, and asynchronous IO.