hoodwink.d enhanced

Fri Jun 19

Andy Warhol paints Debbie Harry on an Amiga

As long as you are rigorous and precise you can be as sloppy as you want.

Prof. Charles Leiserson


Jean-Michel Basquiat


class String def interpolate(assigns = {}) interpolation_context = Struct.new( *assigns.keys ).new(*assigns.values) gsub(/\{([^}]+)\}/) do interpolation_context.instance_eval do eval($1, binding) end end end end s = "Avg: {total/count}, C: {count}, T: {total}" s.interpolate :count => 20, :total => 4556 # => "Avg: 227, C: 20, T: 4556"