require "patternmatching" # You can use local variables or methods inside builder val = 200 code = PatternMatching.build {plus(mul(100, 100), val)} # Another partial style method example class CalcX extend PatternMatching func(:calcx) do seems as {plus(:a, :b)} do calcx(a) + calcx(b) end seems as {mul(:x, :y)} do calcx(a) * calcx(b) end end func(:calcx).seems as {:value} do value end end p CalcX.new.calcx(code)