Class: URI::Component::QueryParamsHash
- Inherits:
-
Hash
- Object
- Hash
- URI::Component::QueryParamsHash
- Defined in:
- lib/uri/component/query.rb
Overview
:nodoc:
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, values) ⇒ Object
- #convert_key(key) ⇒ Object
- #delete(key) ⇒ Object
- #fetch(key, default = nil) ⇒ Object
- #has_key?(key) ⇒ Boolean (also: #include?, #key?, #member?)
- #merge(hash) ⇒ Object
- #merge!(hash) ⇒ Object (also: #update)
- #replace(hash) ⇒ Object
- #store(key, values) ⇒ Object
- #value(key) ⇒ Object
- #value=(key, value) ⇒ Object
- #values(key = nil) ⇒ Object
- #values=(key, values) ⇒ Object
- #values_at(*keys) ⇒ Object
Instance Method Details
#[](key) ⇒ Object
17 18 19 |
# File 'lib/uri/component/query.rb', line 17 def [](key) super(self.convert_key(key)) end |
#[]=(key, values) ⇒ Object
44 45 46 47 |
# File 'lib/uri/component/query.rb', line 44 def []=(key, values) values = [values] unless values.kind_of?(Array) super(self.convert_key(key), values) end |
#convert_key(key) ⇒ Object
14 15 16 |
# File 'lib/uri/component/query.rb', line 14 def convert_key(key) return key.kind_of?(String) ? key : key.to_s end |
#delete(key) ⇒ Object
52 53 54 |
# File 'lib/uri/component/query.rb', line 52 def delete(key) super(self.convert_key(key)) end |
#fetch(key, default = nil) ⇒ Object
20 21 22 |
# File 'lib/uri/component/query.rb', line 20 def fetch(key, default = nil) super(self.convert_key(key), default) end |
#has_key?(key) ⇒ Boolean Also known as: include?, key?, member?
56 57 58 |
# File 'lib/uri/component/query.rb', line 56 def has_key?(key) super(self.convert_key(key)) end |
#merge(hash) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/uri/component/query.rb', line 63 def merge(hash) hash_new = self.class.new hash.each do |key, value| hash_new[key] = value end return hash_new end |
#merge!(hash) ⇒ Object Also known as: update
71 72 73 74 75 76 |
# File 'lib/uri/component/query.rb', line 71 def merge!(hash) hash.each do |key, value| self[key] = value end return self end |
#replace(hash) ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/uri/component/query.rb', line 79 def replace(hash) self.clear hash.each do |key, value| self[key] = value end return self end |
#store(key, values) ⇒ Object
48 49 50 |
# File 'lib/uri/component/query.rb', line 48 def store(key, values) self[key] = values end |
#value(key) ⇒ Object
32 33 34 |
# File 'lib/uri/component/query.rb', line 32 def value(key) return self[key][0] end |
#value=(key, value) ⇒ Object
36 37 38 |
# File 'lib/uri/component/query.rb', line 36 def value=(key, value) self[key] = value end |
#values(key = nil) ⇒ Object
24 25 26 |
# File 'lib/uri/component/query.rb', line 24 def values(key = nil) return key ? self[key] : super end |
#values=(key, values) ⇒ Object
28 29 30 |
# File 'lib/uri/component/query.rb', line 28 def values=(key, values) self[key] = values end |
#values_at(*keys) ⇒ Object
40 41 42 |
# File 'lib/uri/component/query.rb', line 40 def values_at(*keys) super(*keys.map {|key| self.convert_key(key)}) end |