Find an element in an array

Hi,

I have a very basic question: How can I check to see if an array
includes a certain type of element.

Specifically, I an creating an array of file names from a directory on
the server. I then want to identify which items in the array meet a
certain pattern. In my controller I have:

    @files=Dir.entries("/home/bill/PDF")
    render :action => "index", :layout => "visions"

In my view I have:

<% for x in @files %>
<%= link_to x, :action => :show_pdf, :value => x %><br />
<% end %>

In this case, all entries from the directory at listed. I would like
to restrict the links to only those files with a ".pdf" extension. I
assume I need to use regular expression code here, but I don't know
how to do that in this case.

Thanks.

Try the Dir.glob method:
@files = Dir.glob("/home/bill/PDF/*.pdf")

Regards

billv escribió: