Class: Habaki::Selectors

Inherits:
NodeArray show all
Defined in:
lib/habaki/selectors.rb

Overview

Array of Selectors

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NodeArray

#string_join, #to_s

Class Method Details

.parse(data) ⇒ Selectors

parse selectors from string

Parameters:

Returns:



7
8
9
10
11
# File 'lib/habaki/selectors.rb', line 7

def self.parse(data)
  sels = self.new
  sels.parse!(data)
  sels
end

Instance Method Details

#element_match?(element) ⇒ Boolean

does one of theses selectors match Visitor::Element ?

Parameters:

Returns:

  • (Boolean)


28
29
30
31
32
33
# File 'lib/habaki/selectors.rb', line 28

def element_match?(element)
  each do |selector|
    return true if selector.element_match?(element)
  end
  false
end

#parse!(data) ⇒ void

This method returns an undefined value.

parse selectors from string and append to current selectors

Parameters:



16
17
18
19
20
21
22
23
# File 'lib/habaki/selectors.rb', line 16

def parse!(data)
  return unless data

  out = Katana.parse_selectors(data)
  if out.selectors
    read_from_katana(out.selectors)
  end
end

#read_from_katana(sels) ⇒ Object

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.

Parameters:



43
44
45
46
47
# File 'lib/habaki/selectors.rb', line 43

def read_from_katana(sels)
  sels.each do |sel|
    push Selector.read_from_katana(sel)
  end
end

#string(format = Formatter::Base.new) ⇒ String

Parameters:

Returns:



37
38
39
# File 'lib/habaki/selectors.rb', line 37

def string(format = Formatter::Base.new)
  string_join(format, ",")
end