Command-line weather forecast utility powered by WeatherAPI with XML parsing and console output.
A Ruby console application for fetching current weather and 3-day forecasts for any city worldwide. Users enter a city name, the app retrieves XML data and displays information about temperature, humidity, wind speed, UV index, and moon phases.
- 🌍 Weather forecast for any city
- 🌡️ Current temperature, humidity, and wind speed
- 📅 3-day forecast (min/max temperature, weather conditions)
- 🌙 Moon phase information
- ☀️ UV index data
- 📊 XML API integration without external dependencies
- 🖥️ Simple command-line interface
- Ruby 3.2.3 (system Ruby)
- Net::HTTP — HTTP client for API requests
- URI — URL building and validation
- REXML — XML parsing without external gems
- Date — date and time handling
- ✅ Object-Oriented Design: clean separation of concerns with dedicated classes
- ✅ Data Encapsulation:
WeatherForecastclass for weather data representation - ✅ Factory Methods:
location(),current(),forecast()for creating objects from XML nodes - ✅ XML Parsing: navigating element trees with REXML
- ✅ External API Integration: request building, response handling
- ✅ CLI Interface: interaction via standard input/output streams
- ✅ Data Formatting:
to_smethod for human-readable output
weather_xml_2.0/
├── weather_xml_2.0.rb # Main CLI script
├── weather_forecast.rb # Weather data model class
├── README.md # Documentation
└── .gitignore # Ignored files
- Ruby 3.2.3+ (works with system Ruby)
- Internet connection
Run the application:
ruby weather_xml_2.0.rbEnter city name :
MersinWeather forecast for the coming days v 2.0
Information from weatherapi.com
Enter the name of the city Mersin
City: Mersin
Date: 2025-11-05 12:30
Temperature: 21.3°C
Wind: 12.0 km/h
Humidity: 56%
UV index: 4.0
Date: 2025-11-05
Min temperature: 15.0°C
Max temperature: 23.0°C
Wind: 18.0 km/h
Humidity: 60%
Moon phase: Waxing Crescent
UV index: 5.0
Date: 2025-11-06
Min temperature: 16.0°C
Max temperature: 24.0°C
Wind: 15.0 km/h
Humidity: 58%
Moon phase: First Quarter
UV index: 6.0
- REST API Integration: working with external WeatherAPI service
- XML Parsing: processing structured data without libraries like Nokogiri
- HTTP Client: using built-in Net::HTTP
- OOP in Ruby: classes, encapsulation, factory methods
- Output Formatting: creating readable text reports
- Date/Time Processing: parsing and displaying timestamps
- Data Transformation: converting API responses to domain objects