class XPath::Expression::StringLiteral

Public Class Methods

new(expression) click to toggle source
# File lib/xpath/expression.rb, line 124
def initialize(expression)
  @expression = expression
end

Public Instance Methods

to_xpath(predicate=nil) click to toggle source
# File lib/xpath/expression.rb, line 128
def to_xpath(predicate=nil)
  string = @expression
  string = @expression.to_xpath(predicate) unless @expression.is_a?(String)
  if string.include?("'")
    string = string.split("'", -1).map do |substr|
      "'#{substr}'"
    end.join(%q{,"'",})
    "concat(#{string})"
  else
    "'#{string}'"
  end
end