Ruby

My introduction into the world of Ruby

đź“… 24 Jan 2021

Some time back I ran into a problem on a personal project. I wanted to use a assignment from one of my courses as a portfolio project on GitHub, mainly because it used a ton of SQL. The basis of the project was very simple: to analyze the views on different social platforms of restaurants throughout the U.S.

However, as requested by the client, I couldn’t use the data in its current form.

So, I had to go about changing all the data, while trying to keep the spirit of the project. Most of this was pretty easy. I added a random number to all of the number fields and made changes to other variables. When it came to randomizing the restaurant names, however, I ran into issues.

At the time (and I may have missed something), the Faker library for Python did not include a good way to generate restaurant names. I tried generating first and last names using some online tools and then adding random “restaurant” names like “coffee shop”, “grill”, etc., but it just didn’t look good.

Enter Ruby.

I had never used Ruby before, but lo and behold, the Faker library for Ruby had a specific method for restaurant names. Frankly, whoever thought of this is genius. It’s like it was tailor made for my needs.

After some quick installs and configuration changes on my mac, I was up and running with Ruby. Here is the code I used:


  require 'Faker'

  $i = 0
  $num = 15370

  while $i < $num  do
    puts Faker::Restaurant.name
    $i +=1
  end

Note that I could have just as easily written to a csv but it was simple enough to copy from the terminal that I didn’t even bother. A simple copy and paste into excel and I had everything I needed.

I don’t know if I’ll use Ruby much in the future. I guess it just depends on what I want to do. But it was simple enough to set up and use for this project that I may play around with it a bit.

Day 6: #100DaysToOffload



đź’¬ Looking for comments?

I don't have comments on this site because I don't feel like managing them.

Instead of leaving a comment, feel free to ✉️ contact me instead.