Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
To see how we can apply these lofty ideals to real code, let’s imagine that we have been asked to build a message gateway. Our code will have the job of receiving messages and then sending them on to their final destinations. Messages look like this:
require 'uri'
class Message
attr_accessor :from, :to, :body
def initialize(from, to, body)
@from = from
@to = URI.parse(to)
@body = body
end
end