Class Index [+]

Quicksearch

Nokogiri::CSS::Parser

Attributes

cache_on[RW]

Turn on CSS parse caching

Public Class Methods

[](string) click to toggle source

Get the css selector in string from the cache

    # File lib/nokogiri/css/parser.rb, line 17
17:         def [] string
18:           return unless @cache_on
19:           @mutex.synchronize { @cache[string] }
20:         end
[]=(string, value) click to toggle source

Set the css selector in string in the cache to value

    # File lib/nokogiri/css/parser.rb, line 23
23:         def []= string, value
24:           return value unless @cache_on
25:           @mutex.synchronize { @cache[string] = value }
26:         end
clear_cache() click to toggle source

Clear the cache

    # File lib/nokogiri/css/parser.rb, line 29
29:         def clear_cache
30:           @mutex.synchronize { @cache = {} }
31:         end
new(namespaces = {}) click to toggle source

Create a new CSS parser with respect to namespaces

    # File lib/nokogiri/css/parser.rb, line 54
54:       def initialize namespaces = {}
55:         @namespaces = namespaces
56:         super()
57:       end
parse(selector) click to toggle source
 

Parse this CSS selector in selector. Returns an AST.

    # File lib/nokogiri/css/parser.rb, line 43
43:         def parse selector
44:           @warned ||= false
45:           unless @warned
46:             $stderr.puts('Nokogiri::CSS::Parser.parse is deprecated, call Nokogiri::CSS.parse(), this will be removed August 1st or version 1.4.0 (whichever is first)')
47:             @warned = true
48:           end
49:           new.parse selector
50:         end
without_cache(&block) click to toggle source

Execute block without cache

    # File lib/nokogiri/css/parser.rb, line 34
34:         def without_cache &block
35:           tmp = @cache_on
36:           @cache_on = false
37:           block.call
38:           @cache_on = tmp
39:         end

Public Instance Methods

on_error(error_token_id, error_value, value_stack) click to toggle source

On CSS parser error, raise an exception

    # File lib/nokogiri/css/parser.rb, line 76
76:       def on_error error_token_id, error_value, value_stack
77:         after = value_stack.compact.last
78:         raise SyntaxError.new("unexpected '#{error_value}' after '#{after}'")
79:       end
xpath_for(string, options={}) click to toggle source

Get the xpath for string using options

    # File lib/nokogiri/css/parser.rb, line 61
61:       def xpath_for string, options={}
62:         key = "#{string}#{options[:ns]}#{options[:prefix]}"
63:         v = self.class[key]
64:         return v if v
65: 
66:         args = [
67:           options[:prefix] || '//',
68:           options[:visitor] || XPathVisitor.new
69:         ]
70:         self.class[key] = parse(string).map { |ast|
71:           ast.to_xpath(*args)
72:         }
73:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.