NAME attributes.rb URIS http://rubyforge.org/projects/codeforpeople/ http://codeforpeople.com/lib/ruby SYNOPSIS attributes.rb provides a set of attr_* like method with several user friendly additions. attributes.rb is similar to the traits.rb package but sacrifices a few features for simplicity of implementation: attributes.rb is only 42 lines of code. the implimentation of attributes.rb borrows many of the best ideas from the metakoans.rb ruby quiz http://www.rubyquiz.com/quiz67.html in particular the solutions of Christian Neukirchen and Florian Gross. SAMPLES <========< samples/a.rb >========> ~ > cat samples/a.rb # # basic usage is like attr, but note that attribute defines three methods, # getter, setter, and query # require 'attributes' class C attribute 'a' end c = C.new c.a = 42 # setter p c.a # getter p 'forty-two' if c.a? # query # # also not that attribute(s) works as well for objects as classes # o = Object.new o.attribute 'answer' => 42 p o.answer ~ > ruby samples/a.rb 42 "forty-two" 42 <========< samples/b.rb >========> ~ > cat samples/b.rb # # default values may be given either directly or as a block which