class Hpricot::Elements
def remove_class name = nil
(doc/"span").remove_class
Or, to remove all classes:
(doc/"span").remove_class("lightgrey")
Removes a class from all matched elements.
def remove_class name = nil each do |el| next unless el.respond_to? :get_attribute if name classes = el.get_attribute('class').to_s.split(" ") el.set_attribute('class', (classes - [name]).uniq.join(" ")) else el.remove_attribute("class") end end self end