Gem Rat

Earlier this week as I was going to Wegman’s for lunch with my Philly-native co-workers, I mentioned that I had gone to the gym that morning before work. They laughed and asked, “Where’d you go, Kelsey?” “The gym,” I repeated. “The gym?” they inquired, still doubled-over with laughter. “Guys, I don’t understand what’s so funny.” I was unaware of my incorrect pronunciation of this word (which apparently is said like the name ‘Jim’) that would become engrained into my mind for the next 7 days. Not because I was ashamed of my southern-ish accent (I’m not), but because coincidentally the way I say ‘gym’ is the exact thing I was to create by the end of the week — my first ruby ‘gem’.

A gem is basically a package of code that will run a program in the Ruby programming language. I had been learning Ruby for the last 6 weeks but this was my first time building an entire project from a blank slate. The gem had to interact with a user via the Command Line Interface, pull data from an external source, and implement a list and detail view of that data. I actually felt excited and prepared to begin this project, which is a good indicator of my increased skills and confidence level since beginning the Full-Stack Web Development program at Flatiron School. I was bool, balm, and bollected.

Disclaimer: YG did not write this song about coding.

I decided to create a program to read bills from the Pennsylvania congress website. Would I actually use it? Nah. But a friend and I had some ideas running around our heads about a social legislative project for the future, so becoming familiar with governmental data didn’t seem like a total waste of my time.

What my program looks like when initiated.

The code I wrote resides in 3 major files: one to interact with the user, one to ‘scrape’ bill data from the PA General Assembly website, and one to store information about the bills. Each object and the methods to interact with those objects are contained in separate classes. Encapsulation, check.

This guy and I became best buds last week.

I made a few poor assumptions about the PA bill data when I began coding. My first assumption was that there weren’t very many active bills. Turns out there are 1083. My original idea was to start the program and list all the bill numbers with their short titles. Since every bill has its own webpage with its details, iterating through each one at the start of the program is a surefire way to either bang your head against the table for 15 minutes or give yourself a nice break from coding to make and drink another cup of tea while the program is scraping information for each bill. I restructured so that the program only scraped the bill numbers, sans detail, when the program started and fed the user details on an as-requested basis.

The user wanted to view details for Senate bill 481

My second assumption was that a unique bill number cannot exist within both the House and the Senate. I wanted the user to type in only a number to request details on a bill, but realized the user would also have to clarify the branch of the General Assembly to view the correct bill. This was an easy fix but I learned a good lesson. Excuse me while I go re-educate myself on how a bill becomes a law.

Getting this program to function was a lot of fun. It’s not pretty in any sense but it works. I’m already thinking of features I could add — view bills by topic, view bills sponsored by the user’s inputted Representative. But for now I’m happy to be done and ready to move on and learn new things for my next project. Check out my code below.

Like what you read? Give Kelsey Huse a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.