This terminal app was my first programming project, built with Ruby to work in the terminal. The app was over three days in partnership with Steve Christenson. This App allows users to enter a Country and City the want to visit, and returns the monthly climate information for the area. Users can use this app to identify the best time of year to go to their holiday destination.
- Clone the files to your desired directory
- Open Terminal
- Within Terminal, go to the directory where your files will be saved.
- Within Terminal type "bundle install" to install all gems required.
- Within Terminal to run the program, type "ruby main.rb".
People have dream travel destinations, but it can be difficult to find the best time of the year to go.
This travel weather app enables vacationers to easily bring up the yearly weather patterns of any city in the world. They can use this information to determine the time of the year that suits them, based on their climate preferences.
nokogiri: Nokogiri is an HTML, XML, SAX, and Reader parser. Among Nokogiri's many features is the ability to search documents via XPath or CSS3 selectors.
colorize: Extends the String class or add a ColorizedString with methods to set text colour, background colour and text effects.
terminal-table: Simple, feature rich ascii table generation library that enables the creation of tables within the terminal.
- Prompts the user to enter a country and city, or ‘quit’ to exit the program.
- If country or city is not found, prompts the user with “no destination found” and reinitiates the loop.
- If country and city is found, utilises nokogiri methods to scrape climate and astronomical information from www.timeanddate.com
- Arranges the collected information into arrays.
- Utilises terminal-table to display information within arrays in a table format.
- Utilises colorize to colour code temperature, sunrise and sunset information.
- Loop enables the user to input another country and city. Loop continues until user enters ‘quit’ when prompted to enter a country or city.
- Find a web scraping gem. Found Nokogiri.
- Attempted to use Nokogiri methods and syntax to parse a webpage and scrape any information from it
- After some success, attempted to scrape targeted information using additional Nokogiri methods
- Used loops in conjunction with nokogiri methods to methodically collect target information for every month
- Arranged collected information into arrays
- Used terminal-table gem to display collected information
- Used colorize to colour code information
- Looked for a way to handle errors, for when the user input differed from required input. Found the begin-rescue-end method
- Refactored code and rearranged data-scraping code into methods. Also added comments to the body of the app.