Class: Query
- Inherits:
-
Object
- Object
- Query
- Defined in:
- lib/fog/rackspace/client.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add(key, value) ⇒ Object
- #delete(key) ⇒ Object
- #has_key?(key) ⇒ Boolean
-
#initialize(url_params) ⇒ Query
constructor
A new instance of Query.
- #to_s ⇒ Object
- #to_url_params ⇒ Object
Constructor Details
#initialize(url_params) ⇒ Query
Returns a new instance of Query.
60 61 62 63 64 65 66 |
# File 'lib/fog/rackspace/client.rb', line 60 def initialize(url_params) if url_params @params = Query.from_url_params(url_params) else @params = {} end end |
Class Method Details
.from_url_params(url_params) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/fog/rackspace/client.rb', line 75 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
#add(key, value) ⇒ Object
86 87 88 |
# File 'lib/fog/rackspace/client.rb', line 86 def add(key, value) @params[key] = value end |
#delete(key) ⇒ Object
89 90 91 |
# File 'lib/fog/rackspace/client.rb', line 89 def delete(key) @params.delete(key) end |
#has_key?(key) ⇒ Boolean
83 84 85 |
# File 'lib/fog/rackspace/client.rb', line 83 def has_key?(key) @params.has_key? key end |
#to_s ⇒ Object
67 68 69 |
# File 'lib/fog/rackspace/client.rb', line 67 def to_s to_url_params end |
#to_url_params ⇒ Object
70 71 72 73 74 |
# File 'lib/fog/rackspace/client.rb', line 70 def to_url_params elements = [] @params.each_pair {|k,v| elements << "#{k}=#{v}"} elements.join('&') end |