0
0
Rubyprogramming~30 mins

RubyGems repository - Mini Project: Build & Apply

Choose your learning style9 modes available
RubyGems Repository
📖 Scenario: You are managing a small collection of Ruby gems with their versions and descriptions. You want to organize this data and display gems that meet a certain version requirement.
🎯 Goal: Build a Ruby program that stores gem information in a hash, sets a minimum version requirement, filters gems that meet this version, and prints their names and versions.
📋 What You'll Learn
Create a hash called gems with gem names as keys and their version and description as values
Create a variable called min_version to hold the minimum version string
Use a select method to filter gems with version greater than or equal to min_version
Print the filtered gems' names and versions
💡 Why This Matters
🌍 Real World
Managing Ruby gems and their versions is common when developing Ruby applications to ensure compatibility and update control.
💼 Career
Understanding how to organize and filter gem data helps in roles like Ruby developer, DevOps engineer, or software maintainer.
Progress0 / 4 steps
1
Create the gems hash
Create a hash called gems with these exact entries: 'rails' => { version: '7.0.4', description: 'Web application framework' }, 'nokogiri' => { version: '1.13.3', description: 'HTML, XML parser' }, and 'devise' => { version: '4.8.1', description: 'Authentication solution' }.
Ruby
Need a hint?

Use a Ruby hash with string keys and nested hashes for version and description.

2
Set the minimum version
Create a variable called min_version and set it to the string '5.0.0'.
Ruby
Need a hint?

Just assign the string '5.0.0' to min_version.

3
Filter gems by version
Create a variable called filtered_gems that selects gems from gems where the gem's version is greater than or equal to min_version. Use string comparison on the version strings.
Ruby
Need a hint?

Use select with a block comparing info[:version] and min_version.

4
Print filtered gems
Use a for loop with variables name and info to iterate over filtered_gems. Inside the loop, print the gem name and version in the format: "#{name}: #{info[:version]}".
Ruby
Need a hint?

Use a for loop and puts with string interpolation.