public Method

Text.match(conditions)

Returns non-nil if this node meets the given conditions, or nil otherwise. See the discussion of #find for the valid conditions.

Source Code

# File action_controller/vendor/html-scanner/html/node.rb, line 238
def match(conditions)
  case conditions
    when String
      @content == conditions
    when Regexp
      @content =~ conditions
    when Hash
      conditions = validate_conditions(conditions)

      # Text nodes only have :content, :parent, :ancestor
      unless (conditions.keys - [:content, :parent, :ancestor]).empty?
        return false
      end

      match(conditions[:content])
    else
      nil
  end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.