module CrChainableMethods::Pipe

Defined in:

cr_chainable_methods.cr

Macro Summary

Macro Detail

macro pipe(ast) #

This is the way to have a pseudo-operator, the problem is that the gsub will replace the

string everywhere including if it's part of a method argument

The recursive #pipe call will transform the ast like this:

""Hello World Foo Bar" >> (downcase >> (split >> (reverse >> ((join(" - ")) >> unwrap))))" ""Hello World Foo Bar".pipe (downcase.pipe (split.pipe (reverse.pipe ((join(" - ")).pipe unwrap))))" ""Hello World Foo Bar".pipe(downcase.pipe(split.pipe(reverse.pipe((join(" - ")).pipe(unwrap)))))" ""Hello World Foo Bar".downcase.pipe(split.pipe(reverse.pipe((join(" - ")).pipe(unwrap))))" ""Hello World Foo Bar".downcase.split.pipe(reverse.pipe((join(" - ")).pipe(unwrap)))" ""Hello World Foo Bar".downcase.split.reverse.pipe((join(" - ")).pipe(unwrap))" "("Hello World Foo Bar".downcase.split.reverse.join(" - ")).pipe(unwrap)"


[View source]