#My First Cli Project

For my first project at Flatiron School, I utilized the procedural and object oriented Ruby knowledge I obtained from module 1 to create a command-line interface. It allows users to interact with information scraped from a website by typing in commands. I chose to scrape content from a website of my favorite soccer team, Arsenal, using the nokogiri scraper to collect information. As the program opens, the user is greeted with “Welcome to Arsenal FC Squad” and a numbered list of all of the players on the team. The user can then input a number associated with the player’s name to display information about the player. If the user’s input is not within the range of the numbered list, the program asks the user to input a valid choice. The biggest obstacle I encountered while working on my project was trying to get my program to convert non-ASCii characters contained in some of the player names. They included international characters such as ö, é, ñ, which my version of ruby (ruby 2.3.3p222) could not convert. Even after trying out suggestion from google like updating the bundler gem, requiring the addressable gem etc., the error could not be fixed. However, with help from my cohort leader, Z, we were able to remove the player’s name with foreign characters in their names from the squad list using Regex (/[^\x00-\x7F]/).

doc.css(“.squad.sortable tr”)[2..46].each do |player_name|
 name = player_name.css(“td”)[1].text
 unless name.match(/[^\x00-\x7F]/)

The first line in the code above loops through each of the names from the numbered list (.each do |player_name|). The second line of code grabs the second element’s text attribute from player_name.css of “td” and is saved as a variable called name. The third line, however, gives a conditional statement to leave out the names that match the regex, x00-\x7F, which searches for non-ASCII characters. Overall, I really enjoyed working on this project because it allowed me to apply what I learned and build a CLI project. Considering it was my first time building a CLI, I am very satisfied with how it turned out to be. I look forward to building more projects in the future.