Dear Ladies (??) and Gentlemen (okay we have plenty of those),
I wrote a script which needs a variable in order to proceed. This
variable is defined by the user otherwise the default location is
chosen. After a discussion I had on IRC (#ruby @ Freenode), I came up
with a few questions.
My script is structured like this:
I do the ‘control’ of this variable inside the class like this:
@database = database
if @database and File.exists?(@database) <— control
I was wondering if this is the right way actually do this control since,
if @database is not set, the flow will never reach that point, because
the class takes 1 argument (which is @database) and if it’s null, it
will come up with an error.
The script works fine, as is. I optimized it a bit, by removing and/or
optimizing some functions. But I’m curious, where is the right place for
doing this control which is necessary for execution?
ps. Here is the entire script: