Ruby metaprogramming online tutorial [closed]

2019-01-30 03:33发布

问题:

I have just started to learn Ruby and got a good take on the basics. I keep hearing that one of the cool things that Ruby does very well is metaprogramming, but none of the tutorials I've read cover this. Searching Google I can only seem to find paid for ruby metaprogramming screen casts.

So, where can I find a good Ruby metaprogramming tutorial online?

回答1:

The above article does refer to this but I'll post it for clarity: http://viewsourcecode.org/why/hacking/seeingMetaclassesClearly.html



回答2:

If you are prepared to outlay a little cash, then The Pragmatic Programmers website has an excellent screencast series on the Ruby Object Model and metaprogramming. It's not very expensive and is a very comprehensive series that goes over a lot of cool stuff and worth every cent.

I need to watch it again to try and get my head around some of the concepts, then I can be one of the cool meta crowd :)



回答3:

This link explains various concepts(singleton,dynamic programming etc) of Ruby metaprogramming in a very systemetic manner.

http://ruby-metaprogramming.rubylearning.com/



回答4:

These 2 books should get you going...

"The Ruby Programming Language" by Matz and Flanagan.

"Metaprogramming Ruby: Program Like the Ruby Pros" by Paolo Perrota



回答5:

Here is a good introduction for ruby metaprogramming: http://practicalruby.blogspot.com/2007/02/ruby-metaprogramming-introduction.html



回答6:

  • http://rubylearning.com/blog/2010/11/23/dont-know-metaprogramming-in-ruby/
  • http://ruby-metaprogramming.rubylearning.com/
  • http://yehudakatz.com/2009/11/15/metaprogramming-in-ruby-its-all-about-the-self/
  • http://rubyrogues.com/metaprogramming-in-ruby/
  • http://pragprog.com/screencasts/v-dtrubyom/the-ruby-object-model-and-metaprogramming
  • https://github.com/ashbb/ruby_metaprogramming_study_note

These should get you started. and more

  • http://www.vanderburg.org/Speaking/Stuff/oscon05.pdf
  • http://99designs.com/tech-blog/blog/2012/10/30/abusing-ruby-for-fun-and-profit/
  • http://www.amazon.com/Design-Patterns-Ruby-Russ-Olsen/dp/0321490452
  • http://www.apress.com/9781447141259


回答7:

Here is a nice overview: http://ola-bini.blogspot.com/2006/09/ruby-metaprogramming-techniques.html



回答8:

You can take a look at http://rubymonk.com/learning/books/2-metaprogramming-in-ruby - it's the second free book on programming in Ruby that we've release on RubyMonk.com.



回答9:

I'm surprised no one has mentioned Code School. Their "Ruby Bits Part 2" course follows material similar to the second half of the excellent book "Eloquent Ruby.", with a nice set of interactive tests to help drill the material into you.

Link: http://www.codeschool.com/courses/ruby-bits-part-2

Levels:

  1. Blocks, Procs, & Lambdas
  2. Dynamic Classes & Methods
  3. Understanding Self
  4. Missing Methods 5 & 6. DSLs

It does cost $20 a month for a subscription (for which you also get access to all of their other courses), but for me it was totally worth it.