Get the type of an element in Hpricot

342 Views Asked by At

I want to go through the children of an element and filter only the ones that are text or span, something like:

element.children.select {|child|
  child.class == String || child.element_type == 'span'
}

but I can't find a way to test which type a certain element is. How do I test that? I'd like to know that regardless if there's a better way of doing what I'm trying to do, but I also appreciate suggestions on that.

1

There are 1 best solutions below

0
On BEST ANSWER

Found it:

element.name
#=> "span"