Project

pipeblock

0.0
No commit activity in last 3 years
No release in over 3 years
This project was created to improve code reading by passing the return method of a function as the first argument of the next inside a pipe block.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.12
~> 10.0
~> 3.0
 Project Readme

Pipeblock

Pipeblock brings the Pipe Operator flow of Functional Programming to Ruby. It provides a very clean flow for working with static methods.

How to add to Your Project:

gem 'pipeblock'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pipeblock

Usage

# sample method
def cut(text, pattern)
  text.gsub(pattern, '')
end

pipe 'http://www.google.com' do
  cut('http://www.')
  cut('.com')
end
# => google
require 'date'

def add_day(date, days = 1)
  date + days
end

result_date = pipe Date.today do
                add_day 5
                add_day 5
              end

result_date.should > Date.today + 5
result_date.should <= Date.today + 10

Calling external classes

pipe 0.0 do
  e -> (entry_value) { Math.cos entry_value }
end
# => 1.0

License

The gem is available as open source under the terms of the MIT License.