I wrote a program to rename files in a user-defined
directory. The program lets you choose the directory,
type in some "Entries" the strings to replace and the
related strings to replace with.
Then when I click the "Start" button the program perform
the replacements.
This is my first program in Ruby and I am trying to improve
it (e.g make it faster & well coded) do you have any suggestions?
Especially
1) the "Select Directory" FileChooserDialog does not quit when I click
on the "Cancel" Button and it quits only the 2nd time I ckick the "X"
button on the top of the window.
2) is there a way to fill up faster the hash with the strings to
replace?
(e.g. a loop)
I hope you understand my english
Thank you, Giovanni
In your post subject you should mention that you're using Gtk so that
someone with Gtk experience will be likely to respond. I've never used
it so I can't help you with your problem (1)
layout.put(button, 20, 40 + i*40)
button.signal_connect("clicked" do |w|
on_clicked(w)
end
end
The Object class in Ruby is pretty cool and is worth reading through.
I'm not very experienced but it looks like "instance_variable_set"
returns the object that it sets, so you might be able to shorten the
instance variable stuff to: