To demonstrate how to use gems, we will install the redcloth gem.
redcloth library can convert specially formatted text into HTML.
Use gem install RedCloth (or sudo gem install RedCloth) to install the gem.
Once the gem is installed, create a new Ruby source file, and use the redcloth gem like so:
require 'rubygems' require 'RedCloth' r = RedCloth.new("this is a *test* of _using RedCloth_") puts r.to_html
Here, you first load up the RubyGems library, and then load up the RedCloth library with require.
When RubyGems is loaded on the first line, the RubyGems library overrides the require method and loads gems as if they were local libraries.