Class: Hexp::CssSelector::CommaSequence

Inherits:
Object
  • Object
show all
Includes:
Members
Defined in:
lib/hexp/css_selector.rb

Overview

Top level parse tree node of a CSS selector

Contains a number of Sequence objects

For example : ‘span .big, a’

Instance Attribute Summary

Attributes included from Members

#members

Instance Method Summary collapse

Methods included from Members

included, #initialize, #inspect

Instance Method Details

#matches?(element) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Does any sequence in this comma sequence fully match the given element

This method does not recurse, it only checks if any of the sequences in this CommaSequence with a length of one can fully match the given element.

Parameters:

Returns:

  • (Boolean)


102
103
104
105
106
107
108
109
110
111
# File 'lib/hexp/css_selector.rb', line 102

def matches?(element)
  members.any? do |member|
    case member
    when Sequence
      member.members.count == 1 && member.head_matches?(element)
    else
      member.matches?(element)
    end
  end
end

#matches_path?(path) ⇒ Boolean

Returns:

  • (Boolean)


113
114
115
116
117
# File 'lib/hexp/css_selector.rb', line 113

def matches_path?(path)
  members.any? do |sequence|
    sequence.matches_path?(path)
  end
end