RubyGem
Petrel
A RubyGem wrapper for the OpenWeatherMap Free API, providing easy access to weather conditions and forecasts.
Petrel is a lightweight and easy-to-use Ruby library for interacting with the OpenWeatherMap API. It simplifies the process of fetching current weather, forecasts, and "One Call" data for any location.
Features
- Comprehensive Weather Data: Access current weather conditions, 5-day/3-hour forecasts, and detailed "One Call" data.
- Simple Interface: Provides clean Ruby methods like
Petrel.weather(query)to fetch data with minimal boilerplate. - Developer Friendly: Includes features like
awesome_printsupport for easier debugging and clear error handling. - Tested & Reliable: Developed with RSpec to ensure consistent behavior and reliability in production environments.
Installation
Add this line to your application's Gemfile:
gem 'petrel'And then execute:
bundle installUsage
require 'petrel'
Petrel.configure do |config|
config.api_key = 'YOUR_API_KEY'
end
# Fetch current weather for a city
weather = Petrel.weather('San Francisco')
puts "Current temperature: #{weather['main']['temp']}"