Sha256: 03871d055b9cbb2607667ba3ba8ef5b4965be3586137e2b236de8b8b8f1deb27
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 KB
Contents
# Contains Ruby standard library extensions specific to <tt>Twitter4R</tt> library. # Extension to Hash to create URL encoded string from key-values class Hash # 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" def to_http_str result = '' return result if self.empty? self.each do |key, val| result << "#{key}=#{URI.encode(val.to_s)}&" end result.chop # remove the last '&' character, since it can be discarded end end # Extension to Time that outputs RFC2822 compliant string on #to_s class Time alias :old_to_s :to_s # Returns RFC2822 compliant string for <tt>Time</tt> object. # For example, # # Tony Blair's last day in office (hopefully) # best_day_ever = Time.local(2007, 6, 27) # best_day_ever.to_s # => "Wed, 27 Jun 2007 00:00:00 +0100" def to_s self.rfc2822 end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
twitter4r-0.2.3 | lib/twitter/ext/stdlib.rb |
twitter4r-0.2.2 | lib/twitter/ext/stdlib.rb |
twitter4r-0.2.0 | lib/twitter/ext/stdlib.rb |
twitter4r-0.2.1 | lib/twitter/ext/stdlib.rb |