views:

92

answers:

2

I am trying to learn how to write plugins in Rails by learning other people's plugins, turns out it is way harder than I thought.

I found this:

module Facebooker

class AdapterBase
    class UnableToLoadAdapter < Exception; end

What does the fourth line: class UnableToLoadAdapter < Exception; end mean?

What is the best book to learn about more advanced Ruby programming?

Thanks

+3  A: 

It's a way of putting multiple expressions on one line.

class UnableToLoadAdapter < Exception
end

is exactly the same as

class UnableToLoadAdapter < Exception; end
adamse
+2  A: 

Ruby supports ending lines of code with semicolons (;) and allows you to put multiple lines of code onto a single line (for example, x = 10; x += 1; puts x).

Beginning Ruby: From Novice to Professional, 2nd ed. by Peter Cooper

Matthew Rankin
I too used Cooper's book, and thought it provided a very good introduction to Ruby. Soon, however, you'll want something more advanced. "The Ruby Programming Language", by Flanagan and Matsumoto, is a must-have (and handy to have while you're working through the Cooper book.) I've also learned a lot from "Ruby Cookbook", by Carlson and Richardson. "Programming Ruby 1.9", by Thomas et al (and it's predecessor) is reputably very good also. Note if you have the print version of any O'Reilly or Pragmatic Programmer book, you can buy the electronic (searchable!) version at OReilly.com for only $5.
Cary Swoveland