require "patternmatching" # Structured data builder code = PatternMatching.build {plus(mul(100, 100), 200)} # Partial style method example class Calc # At first, extends with the module extend PatternMatching # def calcm(o), as 3 partial styles func(:calcm).seems as {plus(:x, :y)} do calcm(x) + calcm(y) end func(:calcm).seems as {mul(:x, :y)} do calcm(x) * calcm(y) end func(:calcm).seems as {:value} do value end end # use as standard method p Calc.new.calcm(code)