Class: REXML::CSSSelector::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/rexml/css_selector/compiler.rb

Overview

Compiler is a compiler from selectors to queries.

Instance Method Summary collapse

Constructor Details

#initialize(**config) ⇒ Compiler

Returns a new instance of Compiler.



183
184
185
186
# File 'lib/rexml/css_selector/compiler.rb', line 183

def initialize(**config)
  @config = config
  @config[:pseudo_classes] ||= {}
end

Instance Method Details

#compile(selector_list) ⇒ Object



188
189
190
# File 'lib/rexml/css_selector/compiler.rb', line 188

def compile(selector_list)
  compile_selector_list(selector_list)
end

#namespace_name(namespace) ⇒ Object



192
193
194
195
196
197
198
199
# File 'lib/rexml/css_selector/compiler.rb', line 192

def namespace_name(namespace)
  case namespace
  in Namespace[name:]
    name
  in UniversalNamespace[] | nil
    nil
  end
end

#nth_value(nth) ⇒ Object



201
202
203
204
205
206
207
208
209
210
# File 'lib/rexml/css_selector/compiler.rb', line 201

def nth_value(nth)
  case nth
  in Nth[a:, b:]
    [a, b]
  in Odd[]
    [2, 1]
  in Even[]
    [2, 0]
  end
end