Method: HTML::Text#match

Defined in:
lib/action_controller/vendor/html-scanner/html/node.rb

#match(conditions) ⇒ Object

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



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/action_controller/vendor/html-scanner/html/node.rb', line 245

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