Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/githu3/core_ext/hash.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_url_params(url_params = "") ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/githu3/core_ext/hash.rb', line 10

def self.from_url_params(url_params="")
  result = {}
  url_params.split('&').each do |element|
    element = element.split('=')
    result[element[0]] = element[1]
  end
  result
end

Instance Method Details

#to_url_paramsObject



2
3
4
5
6
7
8
# File 'lib/githu3/core_ext/hash.rb', line 2

def to_url_params
  elements = []
  keys.size.times do |i|
    elements << "#{keys[i]}=#{values[i]}"
  end
  elements.join('&')
end