Class: RuboCop::Cop::Capybara::CssAttributesParser Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cop/capybara/mixin/css_attributes_parser.rb

Overview

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

Css selector parser.

Instance Method Summary collapse

Constructor Details

#initialize(selector) ⇒ CssAttributesParser

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.

Returns a new instance of CssAttributesParser.



9
10
11
12
13
14
15
# File 'lib/rubocop/cop/capybara/mixin/css_attributes_parser.rb', line 9

def initialize(selector)
  @selector = selector
  @state = :initial
  @temp = ''
  @results = {}
  @bracket_count = 0
end

Instance Method Details

#parseArray<String>

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.

Returns:

  • (Array<String>)


18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rubocop/cop/capybara/mixin/css_attributes_parser.rb', line 18

def parse # rubocop:disable Metrics/MethodLength
  @selector.each_char do |char|
    if char == '['
      on_bracket_start
    elsif char == ']'
      on_bracket_end
    elsif @state == :inside_attr
      @temp += char
    end
  end
  @results
end