1 # Contains Ruby standard library extensions specific to <tt>Twitter4R</tt> library.
3 # Extension to Hash to create URL encoded string from key-values
5 # Returns string formatted for HTTP URL encoded name-value pairs.
7 # {:id => 'thomas_hardy'}.to_http_str
8 # # => "id=thomas_hardy"
9 # {:id => 23423, :since => Time.now}.to_http_str
10 # # => "since=Thu,%2021%20Jun%202007%2012:10:05%20-0500&id=23423"
13 return result if self.empty?
14 self.each do |key, val|
15 result << "#{key}=#{URI.encode(val.to_s)}&"
17 result.chop # remove the last '&' character, since it can be discarded
21 # Extension to Time that outputs RFC2822 compliant string on #to_s
24 # Returns RFC2822 compliant string for <tt>Time</tt> object.
26 # # Tony Blair's last day in office (hopefully)
27 # best_day_ever = Time.local(2007, 6, 27)
28 # best_day_ever.to_s # => "Wed, 27 Jun 2007 00:00:00 +0100"