This is a basic Ruby on Rails app to display weather for a specified address in the US.
This application requires two environment variables to be set with API keys.
The first is GOOGLE_MAP_API_KEY
, which is used to get information about the
entered address such as the zipcode and geographic coordinates. Instructions for
getting a key can be found at
https://cloud.google.com/docs/authentication/api-keys.
The second required variable is OPENWEATHER_API_KEY
. This is used to retrieve
weather information for the coordinates obtained from the previous API.
Instructions for creating these API keys can be found at
https://openweathermap.org/api.
This application was developed using Ruby version 3.2.2, and it is recommended that Ruby 3.2.x is used to run it. It may work with other versions, but that hasn't been tested.
bundle # Install dependencies specified in `Gemfile`
rails dev:cache # Toggle caching in dev mode to on (assuming it wasn't already on)
rails server # Start development-mode server
The last command there will display a URL, which you can open in your web browser to use the application.
A simple class to represent a temperature. It supports any of the following temperature scales:
- Kelvin
- Degrees Celsius
- Degrees Fahrenheit
Read and write acccessors are available for all of those scales. When
initializing, the desired scale can be passed as a Symbol in the second argument
with :kelvin
being the default.
Some common functionality for working with the geolocation and weather APIs.
Use a geolocation API to get zipcode and coordinates for an address passed as a String.
Use an API to get weather information for a Location. The passed location must respond to the following methods:
- #zipcode
- #latitude
- #longitude
Present a form for the user to enter an address, and display weather at that address.