Cool features, I am really starting to like Ruby. Bas Ed Summers wrote: >On the subject of Ruby, I started out thinking I wanted to port >MARC::Record directly to Ruby but as I worked on it I found myself >using some Ruby idioms that I ended up really liking. > >In particular the Enumerable mixin is really useful for where you want >to allow people to iterate through MARC::Field objects in a >MARC::Record: > > for field in record > ... > end > >Likewise MARC::Subfield objects in a MARC::Field > > for subfield in field > ... > end > >When you mixin Enumerable you also get find() and find_all() >automatically which means you can do this to pull out all the subject >fields for example: > > subjects = record.find_all {|f| ('600'..'699' === f.tag)} > >This block usage is a bit hard to get used to at first, but is an >extremely powerful tool (I believe borrowed from Smalltalk) once you >get used to it. > >Another nice thing in Ruby is that you can define a method like =~ >which allows you to implement your own pattern matching for a class. > > if record =~ /Gravity's Rainbow/ > print "Slothrop" > end > >I guess what I'm really trying to say is that it's pretty interesting >porting APIs from one language to another since it highlights the >strenths of the source and target languages. The tighter you can melt >your libraries into the host language the better. > >//Ed > > > >