More Ruby Zen

Posted: Wed, 22 February 2006 | permalink | No comments

A method to find all files in a directory INCOMING which end with .changes, prepend INCOMING to the matching files, and return the results as an array (desk checked, but not run in anger yet):

def changes_files
  Dir.entries(INCOMING).find_all { |f| 
    f =~ /\.changes$/ }.map { |f| File.join(INCOMING, f) }
end

Line noise it may be, but I'll be damned if it isn't succinct line noise.


Post a comment

All comments are held for moderation; markdown formatting accepted.

This is a honeypot form. Do not use this form unless you want to get your IP address blacklisted. Use the second form below for comments.
Name: (required)
E-mail: (required, not published)
Website: (optional)
Name: (required)
E-mail: (required, not published)
Website: (optional)