# Solution: metakoans.rb

**URL:** <https://www.ruby-forum.com/t/solution-metakoans-rb/53988>\
**Category:** Ruby\
**Created:** [February 19, 2006, 3:07pm UTC](https://www.ruby-forum.com/t/solution-metakoans-rb/53988 "2006-02-19T15:07:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wilson\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/848f3c/32.png) [@Wilson\_B](https://www.ruby-forum.com/u/Wilson_B)\
**Post date:** [February 19, 2006, 3:07pm UTC](https://www.ruby-forum.com/t/solution-metakoans-rb/53988/1 "2006-02-19T15:07:59Z")

</div>

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 name.map {|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}**  
end  
def #{name}?  
true unless #{name}.nil?  
end  
ZEN  
end  
end

# 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

# you
