Class: Rack::Auth::Digest::Params
- Inherits:
-
Hash
show all
- Defined in:
- lib/vendor/rack-1.5.2/lib/rack/auth/digest/params.rb
Constant Summary
collapse
- UNQUOTED =
['nc', 'stale']
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Hash
[], #assoc, constructor_without_key_value_pair_form, #default_proc=, #default_proc_with_nil=, #eql?, #hash, #keep_if, #rassoc, #reverse_merge, #reverse_merge!, #select!, #select_with_hash_return, #stringify_keys, #stringify_keys!, #symbolize_keys, #symbolize_keys!, #to_h, try_convert
Constructor Details
#initialize {|_self| ... } ⇒ Params
Returns a new instance of Params.
23
24
25
26
27
|
# File 'lib/vendor/rack-1.5.2/lib/rack/auth/digest/params.rb', line 23
def initialize
super()
yield self if block_given?
end
|
Class Method Details
.dequote(str) ⇒ Object
13
14
15
16
17
|
# File 'lib/vendor/rack-1.5.2/lib/rack/auth/digest/params.rb', line 13
def self.dequote(str)
ret = (/\A"(.*)"\Z/ =~ str) ? $1 : str.dup
ret.gsub!(/\\(.)/, "\\1")
ret
end
|
.parse(str) ⇒ Object
6
7
8
9
10
11
|
# File 'lib/vendor/rack-1.5.2/lib/rack/auth/digest/params.rb', line 6
def self.parse(str)
Params[*(str).map do |param|
k, v = param.split('=', 2)
[k, dequote(v)]
end.flatten]
end
|
19
20
21
|
# File 'lib/vendor/rack-1.5.2/lib/rack/auth/digest/params.rb', line 19
def self.(str)
str.scan( /(\w+\=(?:"[^\"]+"|[^,]+))/n ).collect{ |v| v[0] }
end
|
Instance Method Details
29
30
31
|
# File 'lib/vendor/rack-1.5.2/lib/rack/auth/digest/params.rb', line 29
def [](k)
super k.to_s
end
|
#[]=(k, v) ⇒ Object
33
34
35
|
# File 'lib/vendor/rack-1.5.2/lib/rack/auth/digest/params.rb', line 33
def []=(k, v)
super k.to_s, v.to_s
end
|
#quote(str) ⇒ Object
45
46
47
|
# File 'lib/vendor/rack-1.5.2/lib/rack/auth/digest/params.rb', line 45
def quote(str)
'"' << str.gsub(/[\\\"]/o, "\\\1") << '"'
end
|
39
40
41
42
43
|
# File 'lib/vendor/rack-1.5.2/lib/rack/auth/digest/params.rb', line 39
def to_s
map do |k, v|
"#{k}=" + (UNQUOTED.include?(k) ? v.to_s : quote(v))
end.join(', ')
end
|