Methods
A
F
N
T
Constants
ALLOW_COMBINATOR_ON_SELF = [:DIRECT_ADJACENT_SELECTOR, :FOLLOWING_SELECTOR, :CHILD_SELECTOR]
 
Attributes
[RW] type

Get the type of this node

[RW] value

Get the value of this node

Class Public methods
new(type, value)

Create a new Node with type and value

# File lib/nokogiri/css/node.rb, line 12
def initialize type, value
  @type = type
  @value = value
end
Instance Public methods
accept(visitor)

Accept visitor

# File lib/nokogiri/css/node.rb, line 18
def accept visitor
  visitor.send(:"visit_#{type.to_s.downcase}", self)
end
find_by_type(types)

Find a node by type using types

# File lib/nokogiri/css/node.rb, line 30
def find_by_type types
  matches = []
  matches << self if to_type == types
  @value.each do |v|
    matches += v.find_by_type(types) if v.respond_to?(:find_by_type)
  end
  matches
end
to_a()

Convert to array

# File lib/nokogiri/css/node.rb, line 47
def to_a
  [@type] + @value.map { |n| n.respond_to?(:to_a) ? n.to_a : [n] }
end
to_type()

Convert #to_type

# File lib/nokogiri/css/node.rb, line 40
def to_type
  [@type] + @value.map { |n|
    n.to_type if n.respond_to?(:to_type)
  }.compact
end
to_xpath(prefix = '//', visitor = XPathVisitor.new)

Convert this CSS node to xpath with prefix using visitor

# File lib/nokogiri/css/node.rb, line 24
def to_xpath prefix = '//', visitor = XPathVisitor.new
  prefix = '.' if ALLOW_COMBINATOR_ON_SELF.include?(type) && value.first.nil?
  prefix + visitor.accept(self)
end