views:

801

answers:

8

I'm looking for a Ruby's equivalent of Code Like a Pythonista: Idiomatic Python

Desirable features:

  • easy to read
  • single document which covers all topics: tips, tricks, guidelines, caveats, and pitfalls
  • size less than a book
  • idioms should work out of the box for the standard distribution (% sudo apt-get install ruby irb rdoc)

Please, put one tutorial per answer if possible, with an example code from the tutorial and its meaning.

UPDATE:

These are the most closest to the above description resources I've encountered:

+3  A: 

While not directly a tutorial, here is a blog that you'll find on topic

http://its.arubything.com/

Jeff
+9  A: 

Here's a slideshow: Idiomatic Ruby.

Excerpt:

'until' works like 'while not'

  x = x * 2 until x > 100
AShelly
+3  A: 

How about Mr. Neigborly's Humble Little Ruby Book

Excerpt:

IO.foreach("textfile.txt") {|line| puts line }
The level of the book is a complete beginner at programming.
J.F. Sebastian
+8  A: 

Ruby Idioms (originally from RubyGarden) is my usual reference for idioms. It's clearly organized and fairly complete. As the author says, these are from RubyGarden, which used to be really cool (thanks Wayback Machine). But now seems to be offline.

Gordon Wilson
+6  A: 

I would suggest the perennial classic: Why's Poignant guide

It's both an introduction to Ruby and an investigation into the Ruby Way.

Toby Hede
I would too, +1. Unfortunately, the OP ruled it out in the comments to the question.
Gordon Wilson
+1  A: 

An executable guide to understanding Ruby's closures, closures-in-ruby.rb.

Otto
+1  A: 

Check out The Ruby Way and The Rails Way, they aren't tutorials but I think they will cover what you're looking for.

Lolindrath
"The Ruby Way" is worth reading.
J.F. Sebastian
+1  A: 

I found this blog recently. Haven't really got into it yet and the couple of posts I have read were a bit beginner focussed. YMMV

http://blog.rubybestpractices.com/

Henry