sanitize_css

sanitize_css(style) Instance Public methods Sanitizes a block of css code. Used by sanitize when it comes across a style attribute

select

select(selector, *values) Instance Public methods

simple_selector

simple_selector(statement, values, can_negate = true) Instance Protected methods Creates a simple selector given the statement and array of substitution values. Returns a hash with the values tag_name, attributes, pseudo (classes) and negation. Called the first time with can_negate true to allow negation. Called a second time with false since negation cannot be negated.

only_child

only_child(of_type) Instance Protected methods Creates a only child lambda. Pass of-type to only look at elements of its type.

nth_child

nth_child(a, b, of_type, reverse) Instance Protected methods Returns a lambda that can match an element against the nth-child pseudo class, given the following arguments: a â Value of a part. b â Value of b part. of_type â True to test only elements of this type (of-type). reverse â True to count in reverse order (last-).

next_selector

next_selector(statement, values) Instance Protected methods Called to create a dependent selector (sibling, descendant, etc). Passes the remainder of the statement that will be reduced to zero eventually, and array of substitution values. This method is called from four places, so it helps to put it here for reuse. The only logic deals with the need to detect comma separators (alternate) and apply them to the selector group of the top selector.

attribute_match

attribute_match(equality, value) Instance Protected methods Create a regular expression to match an attribute value based on the equality operator (=, ^=, |=, etc).

select_first

select_first(root) Instance Public methods Similar to select but returns the first matching element. Returns nil if no element matches the selector.

select

select(root) => array Instance Public methods Selects and returns an array with all matching elements, beginning with one node and traversing through all children depth-first. Returns an empty array if no match is found. The root node may be any element in the document, or the document itself. For example: selector = HTML::Selector.new "input[type=text]" matches = selector.select(element) matches.each do |match| puts "Found text field with name #{match.attributes['name']}" en

next_element

next_element(element, name = nil) Instance Public methods Returns the next element after this one. Skips sibling text nodes. With the name argument, returns the next element with that name, skipping other sibling elements.