Before I started reading “Eloquent Ruby”, I had two options, Either this book or “The Ruby Programming Language”, I had a quick read of the table of contents of both of them, and I decided to go with Russ Olsen’s book.
I have to say, the book is really great.
I never felt boring or unchallenged throughout the book reads (Yes its one of these books that deserve more than one read).
The parts that I liked most were the Metaprogramming and the testing.
I didn’t have a good knowledge of how metaprogramming worked. So it was an eye opener to me the realisation that you can achieve class creation in multiple ways.
The snippet bellow is the culmination of my understanding:
class C1 def m; puts self.class.name + "#" + __method__.to_s ; end end C2 = Class.new C2.class_eval do def m; puts self.class.name + "#" + __method__.to_s ; end end C3 = Class.new do def m; puts self.class.name + "#" + __method__.to_s ; end end C1.new.m C2.new.m C3.new.m
Tell me that the above isn’t elegant!
Another topic that was enjoyable was the different ways
method_missing was used. From error handling, to logging and magic api.
I recommend this book for non ruby developers that want to start learning about ruby, I also recommend it for inexperienced ruby developers that want to gain more insight in ruby internals.