Class: RexleCSS

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

Overview

view test data at

http://rorbuilder.info/r/gemtest/rexle-css/testdata_rexle-css.rdx

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_selector) ⇒ RexleCSS

Returns a new instance of RexleCSS.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rexle-css.rb', line 12

def initialize(raw_selector)

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

  @to_xpath = '//' + selector    
end

Instance Attribute Details

#to_xpathObject (readonly)

Returns the value of attribute to_xpath.



10
11
12
# File 'lib/rexle-css.rb', line 10

def to_xpath
  @to_xpath
end