Rick, mapping a machine template is a complex topic, not what you find in the library from the Ruby library.
Kyle's answer was the beginning, as soon as you get the page with Ruby, the typical technology for this would be xpath or "XML Path Language".
Using Xpath, you can write a simple selector that will extract every element that matches the template, for example, each link in the HTML document can be //a, each h1will be //h1, and each image directly inside the div, where the image has a class of βcarβ, will be something like this : //div/image[class="car"].
XPath , , content() .
Ruby Nokogiri avaiable - , , , .
Ruby , HTML/XML Nokogiri, - Anemone, " - Ruby" - .