Rick and Morty, adventure in coding
Well we’re almost at the end of my first project and boy do I feel like my head is getting filled quickly. I bet you’re wondering why is Rick and Morty in the title well I based my first project around them or rather an API of Rick and Morty. So what was this big project? well it was to create a Command Line Interface application that gets data from an external source. My Project was Rick’s Portal gun to show the user information about different characters and locations from the Rick and Morty show.
To create my app I used Rest-client and JSON to gather my data and parse through it. I also use colorize to make the lines stand out more and added some text to image to create logos. I created an Api Class to handle gather my information from from a base url and created load_characters and load_locations methods that used Rest-client to get data from my base url + the link to either locations or character. Then JSON to parse through and grab the actual body of information we needed and then iterated over that to pull results and store as a new instance of its respective class. I bundled all of this in a while loop in order to get through all the pages of information(there’s like 600+ characters).
Using my Character and Locations classes I was able able to establish an array with all my new characters and define what information I wanted the to initialize will(basically the data I want to show the user later on in the program.
Then I built out my CLI class, the area that holds all the interactions with the user. Here I loaded my API data at the start to keep the program running smoothly once you started it and add built a home_screen method for the user to choose what they wanted to learn about Locations or Characters. From there I had some methods to respond to correct answers and offer the option for more details and methods incase the user answered incorrectly and an option to exit whenever they wanted.
Some things I’d stress to anyone reading this prior to doing their own, Pick an API topic that you love, it will make fooling around with the information more enjoyable. Use binging pry a lot you want to know where and why your program is breaking. Try to use your program incorrectly as much as possible when you think you done, basically answer every question wrong and see does it break, you wanna know before the actual user does and finally find you Jerry to test it that way you don’t disappoint the citadel of Ricks.