My CLI project at Flatiron

Fay Vera
3 min readFeb 5, 2021

Oh the emotional roller coaster this was. It was such a great learning experience, and more than ever, I had to be (VERY) comfortable with failure.

“Ever tried. Ever failed. No matter. Try again. Fail again. Fail better.”- Samuel Beckett

Hearing that, I could guess that Samuel Beckett was coding when he first silently whispered that to himself at 1am, hunched over a laptop — even though he was a writer and director, amongst other things, and was born in 1906.

That may not be the case, but it definitely applied to what I was going through with this project. I had to get comfortable with hitting walls over and over again until there was some sort of breakthrough. Even more, using the failures as clues as to what was working and what wasn’t.

I thought of basing my project on a current event, something that most people could relate to or know about, so the topic of Covid-19 during a global pandemic seemed to ring a few bells. For this project, I decided to focus on the NYC area and its statistics.

I decided to work with an API rather than scrapping a website. The response that I got from it came in form of an array of hashes, and each hash was the data from each day since the first COVID-19 case was first registered. That meant that I wouldn’t need to keep making requests to the API because I already had all the information that I needed to make my application work. Great!

I iterated through the response in order to get to a single hash to see what it was. Throwing in a pry, this is what the first hash looked like:

Turns out I had a lot of data that I didn’t need. At first, I just wanted to access the total number of cases, hospitalizations, and death count, all by date. I later changed my mind and threw in the borough numbers by date as well to give another level to my application. Creating a local variable, I determined what I wanted to extract from each hash from the response, and turning them into a key using the “to_sym” method.

After having the information that I needed, I had to change the date format so that it would be user friendly, and change it to the mm/dd/yyyy format. It took me a while playing around in pry to find something that would work and not be super inconvenient like using “.chop” 13 times.

I used the split method to get rid of the portion of the date that I didn’t need and selected the part that I wanted. Next I split the numbers where they had a dash, rearranged the year position, and joined them with a forward slash “/”.

I then had all I needed to create an instance for each hash! In the end it looked something like this:

I solidified a lot of what was learned in this phase, and I’m looking forward to learning even more!

--

--