Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 31 lines (24 sloc) 0.586 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
require 'expression'

class FileName < Expression
def initialize(pattern)
@pattern = pattern
end

def evaluate(dir)
results = []
Find.find(dir) do |p|
next unless File.file?(p)
name = File.basename(p)
results << p if File.fnmatch(@pattern, name)
end
results
end
end

=begin
expr_all = All.new
files = expr_all.evaluate('/Users/adomokos/Programming/Ruby')

puts files.length

# But if we are just interested in ruby files
expr_ruby_files = FileName.new('*.rb')
ruby_files = expr_ruby_files.evaluate('/Users/adomokos/Programming/Ruby')

puts ruby_files.length
=end
Something went wrong with that request. Please try again.