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(:a, :b)} do calcm(a) + calcm(b) end func(:calcm).seems as {mul(:a, :b)} do calcm(a) * calcm(b) end func(:calcm).seems as {:value} do value end end # use as standard method p Calc.new.calcm(code)