README.md in datapipes-0.1.1 vs README.md in datapipes-0.1.2

- old
+ new

@@ -23,28 +23,26 @@ To handle multi streamings, datapipes offers composabiliy. Source, Tube and Sink are composable individually. So the diagram above will be: ``` - Composed Source works asynchronously + Composed Source works concurrently. [Source Source Source] | - | pipe handles asynchronous + | pipe handles asynchronous. | Tube - Tube Composed Tube has individual tube in series + Tube Composed Tube has individual tube in series. Tube Tube | | | - Sink - Sink - Sink + [Sink Sink Sink] - Composed Sink works synchronously + Composed Sink works concurrently. ``` ## Installation Add this line to your application's Gemfile: @@ -79,11 +77,15 @@ Define `accept?` to recieve the data or skip this. ```ruby class Triple < Datapipes::Tube def run(data) - [data, data, data] + if accept? data + [data, data, data] + else + data + end end def accept?(data) data.is_a? Integer and data > 3 end @@ -93,11 +95,11 @@ Sink consumes piped data. A typical sink is printing data. ```ruby class Print < Datapipes::Sink def run(data) - puts data + puts data if accept? data end def accept?(data) data.is_a? Array and data[0] < 7 end @@ -106,13 +108,12 @@ You can make your own datapipe with your objects. ```ruby datapipe = Datapipes.new( - List.new, # A source - Triple.new, # A tube - Print.new, # A sink - Datapipes::Pipe.new # A pipe + List.new, # A source + Print.new, # A sink + tube: Triple.new, ) ``` Then just run everything with `run_resource`.