Module: StringUtils
- Defined in:
- lib/gyoza-languages/string_utils.rb
Overview
A collection of utilities for strings.
Class Method Summary collapse
-
.query_string_to_hash(string) ⇒ Object
Converts the given query String to a Hash object.
Class Method Details
.query_string_to_hash(string) ⇒ Object
Converts the given query String to a Hash object. A query string is identified by a set of key-value pairs in the format “key=value” separated by the ‘&’ character.
Arguments:
string: the string to convert
13 14 15 16 17 18 19 20 |
# File 'lib/gyoza-languages/string_utils.rb', line 13 def self.query_string_to_hash(string) dict = {} string.split('&').map do |pair| key, value = pair.split('=') dict[key] = value.sub('+', ' ') end dict end |