Re: Working with arrays



I'm not an expert and I can't tell you for sure what to do here, in my own
bot I stored file contents in a variable name and then just rewrote the
file, appending whatever I needed to the end of the variables contents and
then writing the variable to the file. Anyways, back to my reason for
responding, aren't globals slow in Ruby? a friend of mine from deviantART is
always nagging about not using global variables... lol. Anyone feel like
correcting him? And why are you passing in exceptions? :?

--------------------------------------------------
From: "Clement Ow" <clement.ow@xxxxxxxxxxxxxxxxxxx>
Sent: Monday, June 09, 2008 7:05 PM
Newsgroups: comp.lang.ruby
To: "ruby-talk ML" <ruby-talk@xxxxxxxxxxxxx>
Subject: Working with arrays

Hi, people I know some of ya might find me familiar but, I really am
still a novice in ruby thus i'll need help once in awhile. I'd
defeinitely appreciate whatever help that is rendered! =)

ok, so back to our topic. I have a code where I would like to traverse
into files and folders and then at the same time pass in exceptions and
then after that select the whole load of files to carry out actions like
copying or deleting. But I'll only need help for the traversing of
folders and the exceptions part. Here's my code:

src1 = []
$source.each do |y|
Find.find(y + "/") do |file|
src1 << file
$file_exception[i].each do |ex|
src1.delete_if {|x| /#{ex}/ =~ File.basename(file)}

end
end
$source is an array of source paths like ["C:/Del", "C:/My Pictures"]
$file_exception is an array of exceptions like [".txt", ".xls"]

The whole block of code is working fine except that it traverses into
the folders twice, and then parses all the file paths into src1(which is
not what is wanted) Is there any way to improve on my code?
--
Posted via http://www.ruby-forum.com/.



.



Relevant Pages

  • Re: Working with arrays
    ... I have a code where I would like to traverse ... not exceptions. ... folders and the exceptions part. ... Rails training from David A. Black and Ruby Power and Light: ...
    (comp.lang.ruby)
  • Working with arrays
    ... still a novice in ruby thus i'll need help once in awhile. ... I have a code where I would like to traverse ... folders and the exceptions part. ...
    (comp.lang.ruby)
  • Re: what is traverse? I dont get it.
    ... Traversing, with regards to permissions, is when you have access to sub ... folders even though you don't have access to all folders in the path. ... The Bypass traverse checking user right allows the user to browse through ...
    (microsoft.public.win2000.new_user)
  • Re: what is traverse? I dont get it.
    ... Traversing, with regards to permissions, is when you have access to sub ... folders even though you don't have access to all folders in the path. ... The Bypass traverse checking user right allows the user to browse through ...
    (microsoft.public.win2000.setup)
  • Re: what is traverse? I dont get it.
    ... Traversing, with regards to permissions, is when you have access to sub ... folders even though you don't have access to all folders in the path. ... The Bypass traverse checking user right allows the user to browse through ...
    (microsoft.public.win2000.security)