<riceandbeans>
If I want to open a dir, print the children, but also know if a child is a dir, is there a better way than begin Dir.open(child) rescue Errno::ENOENT end
<riceandbeans>
Because Dir.children returns array of string
<riceandbeans>
I guess I want to be like...
<riceandbeans>
child.dir?
<weaksauce>
Dir.exist?
<riceandbeans>
Ok, that'll do
<riceandbeans>
Thanks
<weaksauce>
np
<ccooke>
Dir.exist? is the most concise, simple thing. If you need to check more than just directories, File::Stat.new(file).directory? also works (as do things line file?, pipe?, etc)
<ccooke>
But as weaksauce said, Dir.exist? is the best thing if you just care about directories
<riceandbeans>
Yeah, in this case I was thinking too much at the end instead of the beginning
<riceandbeans>
ie, I'm getting back array of string instead of something typed for a path
<riceandbeans>
But really I could use Dir and feed it back the string
<ccooke>
*nod*
<riceandbeans>
And I've now backed myself into a corner where I should use recursion and don't want to
<riceandbeans>
Intent was to dirwalk and get *.yml
<adam12>
riceandbeans: What's your goal?
<adam12>
riceandbeans: Can you get it through glob? Dir.glob("**/*/yml")
<adam12>
rather, Dir.glob("**/*.yml")
<riceandbeans>
I don't know how many levels there would be
<riceandbeans>
It's arbitrary
<adam12>
That glob shouldn't matter, no?
<riceandbeans>
But, there are some paths wherein I need to reject too
<riceandbeans>
Hmm
<riceandbeans>
Wait a sec
<adam12>
Gotta run. Good luck!
<riceandbeans>
I could Dir.glob().reject!{}
<adam12>
Sure. Rake::FileList is quite nice too, if it came down to it.
<riceandbeans>
Need stdlib
<riceandbeans>
:)
bastienleonard has joined #ruby
saba_sedigh has joined #ruby
<saba_sedigh>
Hello I am on ubuntu 20.04 and apt-get installed 2.7.0 version of ruby. How could I update to latest version?
qunzhong_luxian has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Guest33 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<weaksauce>
saba_sedigh use something like ruby-install
<weaksauce>
you almost never want to use the system ruby