Standard File Naming Conventions in Ruby

Clint Pachl picture Clint Pachl · Oct 21, 2008 · Viewed 26k times · Source

For a file containing the given class, SomeCoolClass, what would be the proper or standard filename?

 1. somecoolclass.rb
 2. some_cool_class.rb
 3. some-cool-class.rb
 4. SomeCoolClass.rb

or some other variation?

I noticed in the Ruby stdlib, versions 1, 2 and 3 are used.

Answer

Daniel Beardsley picture Daniel Beardsley · Oct 21, 2008

With just Ruby (i.e. not Rails), naming is only a convention. In Rails the convention of using underscores is necessary (almost).

I think convention #2 lowercase_and_underscore.rb is more common and looks pretty good, though an article Here says lowercasenounderscore.rb is the Ruby convention.

Pick either which ever convention is more common or which ever one you like more. The most important thing is to be consistent within a project.