class Europeana::API::Record
Public Class Methods
escape(text)
click to toggle source
Escapes Lucene syntax special characters for use in query parameters.
The `Europeana::API` gem does not perform this escaping itself. Applications using the gem are responsible for escaping parameters when needed.
@param [String] text Text to escape @return [String] Escaped text
# File lib/europeana/api/record.rb, line 36 def escape(text) fail ArgumentError, "Expected String, got #{text.class}" unless text.is_a?(String) specials = %w<\\ + - & | ! ( ) { } [ ] ^ " ~ * ? : /> specials.each_with_object(text.dup) do |char, unescaped| unescaped.gsub!(char, '\\\\' + char) # prepends *one* backslash end end