Ruby - The Core Language, Bellevue 2013
- Informed by Ruby Style Guide
- Class requirements
- Spacing
- 2 spaces per indent - no tabs
- spaces in methods only if required to separate ideas
- one space between methods
- Case
- snake_case variables
- CamelCase classes
- SCREAMING_SNAKE_CASE for constants
- Methods
- named what it returns not what it does (names, not get_names)
- predicate methods end in a question mark (empty?)
- dangerous methods end in an exclamation mark, where non-dangerous version exists (uniq and uniq!)
- rarely more than 5 or 10 LOC
- omit parenthesis, usually
- prefer {...} over do...end for single line blocks
- avoid perl style special variables (
$0, $ `, etc)
- Spacing