Skip to content

RubyArtm/weather_xml_2.0

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Weather Forecast CLI (Ruby)

Command-line weather forecast utility powered by WeatherAPI with XML parsing and console output.

📋 Description

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.

✨ Features

  • 🌍 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

🛠️ Technologies & Implementation

Language and Standard Libraries

  • 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

Skills and Patterns

  • Object-Oriented Design: clean separation of concerns with dedicated classes
  • Data Encapsulation: WeatherForecast class 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_s method for human-readable output

📂 Project Structure

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

🚀 Usage

Requirements

  • Ruby 3.2.3+ (works with system Ruby)
  • Internet connection

Setup

Run the application:

ruby weather_xml_2.0.rb

Enter city name :

Mersin

📖 Usage Example

Weather 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

🎯 Skills Demonstrated

  • 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages