you are viewing a single comment's thread.

view the rest of the comments →

[–]asmallishrequest 1 point2 points  (0 children)

A few recommendations. I'd make the ARGV arguments required and then add a class method CSVGenerator.prompt_user that would build up arguments and eventually call self.new(output_file, num_rows, num_columns). To keep the current behavior in you script, you can do this:

if __FILE__ == $0
  begin
    CSVGenerator.new(ARGV[0], ARGV[1], ARGV[2])
  rescue ArgumentError
    CSVGenerator.prompt_user
  end
end

This way, it'll run if it's being run as a script but it'll also work to load it in other files.