Extension to Hash to create URL encoded string from key-values
Methods
Public Instance methods
Returns string formatted for HTTP URL encoded name-value pairs. For example,
{:id => 'thomas_hardy'}.to_http_str
# => "id=thomas_hardy"
{:id => 23423, :since => Time.now}.to_http_str
# => "since=Thu,%2021%20Jun%202007%2012:10:05%20-0500&id=23423"
[ show source ]
# File lib/twitter/ext/stdlib.rb, line 11
11: def to_http_str
12: result = ''
13: return result if self.empty?
14: self.each do |key, val|
15: result << "#{key}=#{URI.encode(val.to_s)}&"
16: end
17: result.chop # remove the last '&' character, since it can be discarded
18: end