Visit the published gem page at rubygems.org
Use 'gem install ruby-cheerio' for adding it to your gem-list
You can add 'gem ruby-cheerio' to your Gemfile and run 'bundle install'.
Adding ruby-cheerio to your code
require 'ruby-cheerio'
jQuery is just a variable here.
jQuery = RubyCheerio.new("<html><body><h1 class='one'>h1_1</h1><h1>h1_2</h1></body></html>")
The .find method on a cheerio object with 'selectors', which can be a class, id, element name or all together.
jQuery.find('h1').each do |head_one|
p head_one.text
end
The .prop method can return the value of the attribute. Here 'class' is the attribute needed and 'h1' is the selector again.
p jQuery.find('h1.one')[0].prop('h1','class')
You can find some interesting code samples here: Sample Code