Module: Riak::Util::Escape

Included in:
Bucket, Client, Client::HTTPBackend, Link, MapReduce, RObject, RObject, WalkSpec
Defined in:
riak-client/lib/riak/util/escape.rb

Overview

Methods for escaping URL segments.

Instance Method Summary (collapse)

Instance Method Details

- (String) escape(bucket_or_key)

CGI-escapes bucket or key names that may contain slashes for use in URLs.

Parameters:

  • bucket_or_key (String)

    the bucket or key name

Returns:

  • (String)

    the escaped path segment



23
24
25
# File 'riak-client/lib/riak/util/escape.rb', line 23

def escape(bucket_or_key)
  CGI.escape(bucket_or_key.to_s).gsub("+", "%20")
end

- (String) unescape(bucket_or_key)

CGI-unescapes bucket or key names

Parameters:

  • bucket_or_key (String)

    the bucket or key name

Returns:

  • (String)

    the unescaped name



30
31
32
# File 'riak-client/lib/riak/util/escape.rb', line 30

def unescape(bucket_or_key)
  CGI.unescape(bucket_or_key.to_s)
end