Ruby coding conventions, standards and best practices

Since Rails is  the most popular framework based on the Ruby language today, I appreciate what the Rails developer site has to say about “source style”:

  • Two spaces, no tabs
  • Don’t use “and” and “or” for boolean tests, instead always use “&&” and “| |”
  • MyClass.my_method(my_arg) — not my_method( my_arg ) or my_method my_arg
  • Follow the conventions you see used in the source already

Tabs in code are cancerous to me (e.g. display versus printing fidelity woes), but I prefer three or four spaces to two, depending on the prevailing code base–three spaces if setting precedent (e.g. start of indented line following conditional such as “if (” lines up with the condition itself).

Digging a little deeper, I found the following pages worthwhile:

What do you use on your Ruby-related projects?

-Craig
http://craigrandall.net/
@craigsmusings