Class: Hash

Inherits:
Object show all
Defined in:
opal/browser/utils.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.decode_uri(string) ⇒ Hash

Decode an URL encoded form to a Hash.

Parameters:

  • string (String)

    the URL encoded form

Returns:


58
59
60
61
62
63
64
# File 'opal/browser/utils.rb', line 58

def self.decode_uri(string)
  self[string.split(?&).map {|part|
    name, value = part.split(?=)

    [name.decode_uri_component, value.decode_uri_component]
  }]
end

Instance Method Details

#encode_uriString

Encode the Hash to an URL form.

Returns:

  • (String)

    the URL encoded form


69
70
71
72
73
# File 'opal/browser/utils.rb', line 69

def encode_uri
  map {|name, value|
    "#{name.to_s.encode_uri_component}=#{value.to_s.encode_uri_component}"
  }.join(?&)
end