Sha256: ff7bdc43a6e4097bb3f4379816ffe61000ee989a90a3f064e2f2f7abf63283c7

Contents?: true

Size: 521 Bytes

Versions: 3

Compression:

Stored size: 521 Bytes

Contents

# A module that contains (1) string related methods
module RSolr::Char
  
  # backslash everything
  # that isn't a word character
  def escape value
    value.gsub /(\W)/, '\\\\\1'
  end
  
  # LUCENE_CHAR_RX = /([\+\-\!\(\)\[\]\^\"\~\*\?\:\\]+)/
  # LUCENE_WORD_RX = /(OR|AND|NOT)/
  # 
  # # More specific/lucene escape sequence
  # def lucene_escape string
  #   delim = " "
  #   string.gsub(LUCENE_CHAR_RX, '\\\\\1').split(delim).map { |v|
  #     v.gsub(LUCENE_WORD_RX, '\\\\\1')
  #   }.join(delim)
  # end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rsolr-1.0.2 lib/rsolr/char.rb
rsolr-1.0.1 lib/rsolr/char.rb
rsolr-1.0.0 lib/rsolr/char.rb