Solution: metakoans.rb


Great quiz. Thanks for writing it. Sorry to post this after exactly
48 hours, but I have to start a road trip in about 10 minutes, and
wanted to get this out first.

I managed to get the code down to 15 lines without semicolons or
anything particularly in need of wrapping. However, 42 seemed like
such a good number that I padded my solution out with poems by Ikkyu.

I couldn’t quite wrap my head around a solution that avoided the
string form of class_eval, but hopefully someone managed it.

so many paths go up from the foothills

but one moon grazes the peak

stare at it until your eyes drop out

this desk this wall this unreal page

the edges of the sword are life and death

no one knows which is which

inside the koan clear mind

gashes the great darkness

class Module
def attribute(name, &block)
return {|k,v| attribute(k) {v}} if name.is_a?(Hash)
define_method("#{name}", block || proc{nil})
class_eval <<-ZEN
attr_writer :#{name}
def #{name}
defined?(@#{name}) ? @#{name} : @#{name} = #{name}
def #{name}?
true unless #{name}.nil?

clouds endless clouds climbing beyond

ask nothing from words on a page

lone moon, no clouds

we stumble through the night

long life

the wild pines want it too

mirror facing a mirror

nowhere else

only one koan matters