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

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

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -