Sha256: d5d2cd916f973533773051b78f29fde9db5f5f295317d1a94f94f7c2ab9799ab

Contents?: true

Size: 334 Bytes

Versions: 2

Compression:

Stored size: 334 Bytes

Contents

class Hash
  
  def to_query
    require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
    self.collect do |key, value|
      "#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}"
    end.sort * '&'
  end
  
  def key
    self.keys.first if self.length == 1
  end

  def value
    self.values.first if self.length == 1
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cannikin-gattica-0.1.4 lib/gattica/core_extensions.rb
cannikin-gattica-0.2.0 lib/gattica/core_extensions.rb