Morning with your favorite NEWS

Simran Manandhar
3 min readNov 16, 2020

After a three week long of learning new codes and debugging them, the last one week passed by in a click with late night sleeps. Yes, lots of error and the excitement of solving them made me a night owl for a person who is always tired and sleeping. Then, finally completing with a video demonstration is such a relief.

I came across the NEWS API, that extract news from all over the world. The API has a collection of articles from different authors. In my project, I pulled out the id, author, title and content. I’ve added 4 features, they are: Searching articles of our own choice, Look into the search history, Save the article in order to read it later and Delete the saved articles. It’s a very simple and short app but when we look inside, it’s a lot of coding.

Home page of my News App

The next morning after I parsed the API, my program threw an error. But, I was sure that before I slept, my code was running fine. It took me an hour to figure out what the issue was about. It was the yesterday’s date in the API link that was sending the error. As the news we read are in daily basis, the date needs to be updated daily. For this to happen, I used Time class that would take the current date whenever we run the app.

I have used the enumerator: each throughout my project. It is the most suitable method for displaying the searched articles, the search history and the saved articles.

To delete the saved articles, I found out the easiest way which was by using the delete_at method. It deletes the element that we want to delete just by passing the index number.

During this project, I made binding.pry my best friend. I used it in each and every methods. This command is a life saver because, we can actually go inside our code and try out everything. If we get an error, we can walkthrough our code by getting inside that part. In order to use pry, you need to add require “pry” in your file or you can also add gem ‘pry’ to your gem file and then install it by running the code bundle install in your terminal.

In the future, I’ll also be adding a feature to search your favorite channel and subscribe to it.

Here’s my CLI project demo if you are interested.

https://www.youtube.com/watch?v=49u6kwSTNQg&t=1s

--

--