DEV Community

Swislok-Dev
Swislok-Dev

Posted on

Ruby CLI App

I wrote a CLI application that grabs info about dogs from an API.
This was a very rushed project as I had fallen behind, but was able to get everything working how I wanted them to be. The file structure was pretty simple and straightforward.
This was the first time I had worked with an API so I did not really know what I was doing with this at first. After understanding the iron plate code used in the API class, I was able to define the class variable which was the endpoint for the API and send a get request which was to be parsed to JSON format. I had a few days playing with this to misunderstand where each breed object was being stored (inside the Breed class I made on day one). This was my biggest trouble spot after which helped make namespacing make more sense.
The app has simple phrases that tell the user plainly what is happening and being asked. All the data is ready and objects created are all listed out to show the user each breed that can be selected by entering the corresponding number. Any information that is available is shown and the user is prompted if they would like to run more queries of a different breed. Most breeds would be able to show all data while others would have some extra details that were omitted for continuity. It was nice to see the API included both imperial and metric measurements for height and weight. Although imperial measurements were used, it could be swapped and possibly have both shown to not leave any question regarding the general size of a given breed.
For each breed object that was created, I used mass assignment as each breed had different attributes to be added (more or less) between them. Much of the error correction was used to point the user back to the request.

Top comments (0)