Ruby Style Guide

Theory

Practice

See also:

Filesystem Layout:

Examples

File Composition:

File layout:

  1. Shebang, if executable
  2. Encoding line, if not ASCII
  3. requires of stdlib
  4. requires of gems or framework source
  5. requires of source from same app
  6. Usage comment, if a script
  7. Module and class definitions
  8. Method definitions
  9. Wrapped execution in if $0 == __FILE__, if executable
  10. __END__ and bundled data, if any

Examples

Block style:

Flow control:

Classes:

Methods:

General code style:

Naming:

Comments:

Testing:

Optimization:

Misc Engineering:

General: