dracos
November 9, 2007, 7:54am
1
I see this question was asked a while back
(http://www.ruby-forum.com/topic/84762 ), but I’m having trouble
implementing any of the solutions. I have tried:
if Dir[“#{RAILS_ROOT}/documents/”].empty?
if catch(‘empty’){Dir.glob(“#{RAILS_ROOT}/documents/”){throw ‘empty’}}
if Dir.entries(“#{RAILS_ROOT}/documents/”) == []
, but none seem to work for me.
dracos
November 9, 2007, 10:35am
2
On Nov 9, 1:54 pm, Peter M. [email protected] wrote:
if Dir[“#{RAILS_ROOT}/documents/”].empty?
try this.
if Dir[“#{RAILS_ROOT}/documents/*”].empty?
dracos
November 9, 2007, 6:46pm
3
2007/11/9, Peter M. [email protected] :
I see this question was asked a while back
(Test if Directory is Empty - Ruby - Ruby-Forum ), but I’m having trouble
implementing any of the solutions. I have tried:
if Dir[“#{RAILS_ROOT}/documents/”].empty?
You need the star here as well - as you probably know by now.
if catch(‘empty’){Dir.glob(“#{RAILS_ROOT}/documents/”){throw ‘empty’}}
I guess that should rather read
unless catch(‘non_empty’){Dir.glob(“#{RAILS_ROOT}/documents/*”){throw
‘non_empty’}}
Or am I missing something?
if Dir.entries(“#{RAILS_ROOT}/documents/”) == []
(see above)
, but none seem to work for me.
Cheers
robert
dracos
November 9, 2007, 11:57am
4
pphetra wrote:
try this.
if Dir["#{RAILS_ROOT}/documents/*"].empty?
Ahh, didn’t see the stars. Thanks pphetra