Class: RexleCSS

Inherits:
Object
  • Object
show all
Defined in:
lib/rexle-css.rb

Overview

file: rexle-css.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_selector) ⇒ RexleCSS

Returns a new instance of RexleCSS.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rexle-css.rb', line 9

def initialize(raw_selector)

  selector = raw_selector\
          .gsub(/(\w+)#(\w+)/,'\1[@id="\2"]')\
          .gsub(/#(\w+)/,'.[@id="\1"]')\
          .gsub(/\.(\w+)/,'[@class="\1"]')\
          .gsub(/ /,'//').gsub(/>/,'/')\
          .gsub(/^\*$/,'.')

  @to_xpath = '//' + selector    
end

Instance Attribute Details

#to_xpathObject (readonly)

Returns the value of attribute to_xpath.



7
8
9
# File 'lib/rexle-css.rb', line 7

def to_xpath
  @to_xpath
end