Introducing the Rexle-css gem

require 'rexle-css'

RexleCSS.new('#foo').to_xpath         #=> 
div[@id="foo"]
RexleCSS.new('foo').to_xpath          #=> 

foo

RexleCSS.new('foo bar').to_xpath      #=> //foo//bar
RexleCSS.new('article#main').to_xpath #=> 
article[@id="main"]
RexleCSS.new('.shaded').to_xpath      #=> 

[@class="shaded"]

RexleCSS.new('div.shaded').to_xpath   #=> 
div[@class="shaded"]
RexleCSS.new('span div.shaded').to_xpath  #=> 

span//div[@class="shaded"]

RexleCSS.new('span>div').to_xpath     #=> //span/div

The Rexle-css gem is intended to be used internally by the Rexle gem to facilitate transforming a CSS selector into an XPath.

Resources

Tags:
Source:
2038hrs.txt
Published:
19-10-2014 20:38