Overview of private versus public methods
This is going to be a fun section, as we are going to talk about sending an SMS message. Also, you will learn about how Ruby works with private and public methods.
Now, I'll go back to the ApiConnector
class and create a class called SmsConnector
that inherits from the ApiConnector
class. In this class, I will create a method called send_sms
. Inside this method, I'm going to place a code that will run a script that contacts an API that I created; it will look like this:
class SmsConnector < ApiConnector def send_sms `curl -X POST -d "notification[title]=#{@title}" -d "notification[url]=http://edutechional-resty.herokuapp.com/posts/1" "#{@url}"` end end
This method will send a title and link to an API, which will, in turn, send an SMS message. You don't have to worry about the code that will be handling the actual SMS sending, which is part of the beauty of the implementation.
Hopefully, you'll notice that the URL in the method...