ruby - Get relative path to every file in a directory -



ruby - Get relative path to every file in a directory -

how relative path every file in directory? if utilize dir["path/to/folder/*"] outputs whole path.

dir#entries looking for:

dir.entries("dir").each { |f| puts f } # ⇒ makefile # ⇒ text.doc # ⇒ ...

please aware result may contain . , ... prevent appearance of in result, might want utilize array#reject (creds @iain, snippet filter hidden files on *nices):

dir.entries("dir").reject{ |e| e.start_with? '.' }.each { |f| puts f }

other alternative dir#chdir before executing glob.

hope helps.

ruby sinatra

Comments

Popular posts from this blog

javascript - THREE.js reposition vertices for RingGeometry -

javascript - I need to update the text of a paragraph by inline edit -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -