Class: Capybara::Selector::CSS::Splitter

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/selector/css.rb

Instance Method Summary collapse

Instance Method Details

#split(css) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/capybara/selector/css.rb', line 33

def split(css)
  selectors = []
  StringIO.open(css.to_s) do |str|
    selector = +''
    while (char = str.getc)
      case char
      when '['
        selector << parse_square(str)
      when '('
        selector << parse_paren(str)
      when '"', "'"
        selector << parse_string(char, str)
      when '\\'
        selector << (char + str.getc)
      when ','
        selectors << selector.strip
        selector.clear
      else
        selector << char
      end
    end
    selectors << selector.strip
  end
  selectors
end