Dir operations are performed on the directory they're called from, regardless of what directory you feed in. So Dir.glob
or Dir.foreach
or Dir.entries
on (base_dir + '*.something').count
won't return expected results.
You'll need to change directory, then perform the operation, e.g.
Dir.chdir(base_dir)
Dir.glob('*.something').count