Class: Rbkb::Http::Parameters
Overview
The Parameters class is for handling named parameter values. This is a stub base class from which to derive specific parameter parsers such as:
FormUrlencodedParams for request query string parameters and POST
content using application/www-form-urlencoded format.
MultiPartFormParams for POST content using multipart/form-data
Class Method Summary
collapse
Instance Method Summary
collapse
#_common_init, #opts, #opts=
Methods inherited from Array
#rand_elem, #randomize
Constructor Details
#initialize(*args) ⇒ Parameters
Returns a new instance of Parameters.
17
18
19
|
# File 'lib/rbkb/http/parameters.rb', line 17
def initialize(*args)
_common_init(*args)
end
|
Class Method Details
.parse(str) ⇒ Object
13
14
15
|
# File 'lib/rbkb/http/parameters.rb', line 13
def self.parse(str)
new().capture(str)
end
|
Instance Method Details
#delete_param(k) ⇒ Object
62
63
64
|
# File 'lib/rbkb/http/parameters.rb', line 62
def delete_param(k)
self.delete_if {|p| p[0] == k }
end
|
#get_all(k) ⇒ Object
21
22
23
|
# File 'lib/rbkb/http/parameters.rb', line 21
def get_all(k)
self.select {|p| p[0] == k}
end
|
#get_all_values_for(k) ⇒ Object
Also known as:
all_values_for
25
26
27
|
# File 'lib/rbkb/http/parameters.rb', line 25
def get_all_values_for(k)
self.get_all(k).collect {|p,v| v }
end
|
#get_param(k) ⇒ Object
30
31
32
|
# File 'lib/rbkb/http/parameters.rb', line 30
def get_param(k)
self.find {|p| p[0] == k}
end
|
#get_value_for(k) ⇒ Object
Also known as:
get_param_value, value_for
34
35
36
37
38
|
# File 'lib/rbkb/http/parameters.rb', line 34
def get_value_for(k)
if p=self.get_param(k)
return p[1]
end
end
|
#set_all_for(k, v) ⇒ Object
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/rbkb/http/parameters.rb', line 51
def set_all_for(k, v)
sel=self.get_all(k)
if sel.empty?
self << [k,v]
return [[k,v]]
else
sel.each {|p| p[1] = v}
return sel
end
end
|
#set_param(k, v) ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'lib/rbkb/http/parameters.rb', line 42
def set_param(k, v)
if p=self.get_param(k)
p[1]=v
else
p << [k,v]
end
return [[k,v]]
end
|