Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/gattica/core_extensions.rb
Instance Method Summary collapse
Instance Method Details
#key ⇒ Object
10 11 12 |
# File 'lib/gattica/core_extensions.rb', line 10 def key self.keys.first if self.length == 1 end |
#stringify_keys ⇒ Object
18 19 20 21 22 23 |
# File 'lib/gattica/core_extensions.rb', line 18 def stringify_keys inject({}) do |, (key, value)| [key.to_s] = value end end |
#to_query ⇒ Object
3 4 5 6 7 8 |
# File 'lib/gattica/core_extensions.rb', line 3 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 |
#value ⇒ Object
14 15 16 |
# File 'lib/gattica/core_extensions.rb', line 14 def value self.values.first if self.length == 1 end |