Sha256: 2c657dba0ae03cfe1af4720dd06a4dc545147211428cb5792654c4862c1f82b0

Contents?: true

Size: 387 Bytes

Versions: 5

Compression:

Stored size: 387 Bytes

Contents

module Gattica
  module HashExtensions

    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
end

Version data entries

5 entries across 5 versions & 4 rubygems

Version Path
readmedia-gattica-0.6.2.1 lib/gattica/hash_extensions.rb
chrisle-gattica-0.6.3 lib/gattica/hash_extensions.rb
songphi-gattica-0.5.3 lib/gattica/hash_extensions.rb
betapond-gattica-0.5.2 lib/gattica/hash_extensions.rb
betapond-gattica-0.5.1 lib/gattica/hash_extensions.rb