concept message in category ruby

This is an excerpt from Manning's book The Well-Grounded Rubyist, Third Edition.
Ruby sees all data structures and values—from simple scalar (atomic) values like integers and strings, to complex data structures like arrays—as objects. Every object is capable of understanding a certain set of messages. Each message that an object understands corresponds directly to a method—a named, executable routine whose execution the object has the ability to trigger.
Objects are represented either by literal constructors—like quotation marks for strings—or by variables to which they’ve been bound. Message sending is achieved via the special dot operator: the message to the right of the dot is sent to the object to the left of the dot. (There are other, more specialized ways to send messages to objects, but the dot is the most common and fundamental way.) Consider this example from table 1.1:
x = "100".to_iThe dot means that the message to_i is being sent to the string "100". The string "100" is called the receiver of the message. We can also say that the method to_i is being called on the string "100". The result of the method call—the integer 100—serves as the right-hand side of the assignment to the variable x.
In practice, the message being sent is almost always the name of a method (like talk, the method defined earlier). The object always tries to act on the assumption that the message is the name of a method. If there’s no method by that name, error-handling measures are taken.

This is an excerpt from Manning's book Ruby in Practice.
So, why is Ruby popular now? This popularity can, for the most part, be traced to developers growing weary of complex, taxing development tools and to the emergence of Rails as a definite, tangible project that shows how Ruby can be used to create production quality software that’s still developer friendly. Once you start working with Ruby, you’ll probably realize this too. It takes about the same amount of effort to work with flat files, produce PDFs, make SOAP requests, and send messages using WebSphere MQ as it does to map objects to databases, send email, or parse an XML file. Wrap that into a nice, natural syntax, and you have a potent tool for software development.
But these are all business-to-consumer use cases. What about automating email for things like your continuous integration server or process-monitoring software? You can use email as a powerful way to alert or update people about the state of a system. You could also use automated email reception for tasks like creating new tickets in your development ticketing system or setting up autoresponders for email addresses (for example, a user sends an email to autoresponse@yourdomain.com, and then emails are automatically responded to with the message in the body for that address). Email’s ubiquity makes it a powerful tool for communication in your Ruby applications, and in this section we’ll show you how to harness email to do your (Ruby-powered) bidding. We’ll cover the basics, like sending and receiving, and then look at processing email with Ruby.
Creating a message with MailFactory is as simple as creating a MailFactory object, setting the proper attributes, and then getting the object’s string value, a properly formatted SMTP message. Listing 6.1 shows a short example.
As you can see, setting up a MailFactory object is fairly straightforward: instantiate, populate, and output the message to a string.
Now, all you need to do is feed the message to Net::SMTP to send it. To send an email to your system administration team every time your Apache web server process crashes, you just need to build a MailFactory object, giving it a string of recipients, and then send it via Net::SMTP. Listing 6.2 shows our implementation.
. Then we find a user (in this case, “youraimuser”), send a simple message
, and disconnect from AIM. This approach works well when you’re simply sending messages, but it gets awkward when you want to deal with incoming messages.