It’s quite easy. Make sure you have RubyGems and Ruby installed first, of course.
$ sudo gem install hpricot
Building native extensions. This could take a while...
ERROR: Error installing hpricot:
ERROR: Failed to build gem native extension.
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)