Complete the code to install a gem named 'rails' using RubyGems.
system('gem [1] rails')
The gem install command installs a gem from the RubyGems repository.
Complete the code to list all installed gems using RubyGems.
system('gem [1]')
The gem list command shows all gems installed on your system.
Fix the error in the code to search for a gem named 'nokogiri' in the RubyGems repository.
system('gem [1] nokogiri')
The gem search command looks for gems in the RubyGems repository.
Complete the code to create a hash that maps gem names to their versions for gems with version greater than 2.0.
gems = gem_list.each_with_object({}) { |(name, version), h| h[name=>version] = version if version [1] '2.0' }In Ruby, hashes use h[name => version] to map keys to values within each_with_object({}). The condition checks if version is greater than '2.0'.
Fill all three blanks to create a hash that maps gem names in uppercase to their versions if version is less than '3.0'.
result = gems.each_with_object({}) { |(name, version), h| h[name[1] => version] if version [2] '3.0' and name[3] }The .upcase method converts the gem name to uppercase. The condition checks if version is less than '3.0' and name is not empty.