class Merged
Used for merging objects into a sequential list of headers. Normalizes header keys and values.
Definitions
def initialize(*all)
Construct a merged list of headers.
Signature
-
parameter
*all
Array
An array of all headers to merge.
Implementation
def initialize(*all)
@all = all
end
def fields
Signature
-
returns
Array
A list of all headers, in the order they were added, as
[key, value]
pairs.
Implementation
def fields
each.to_a
end
def flatten
Signature
-
returns
Headers
A new instance of
class Protocol::HTTP::Headers
containing all the merged headers.
Implementation
def flatten
Headers.new(fields)
end
def clear
Clear the references to all headers.
Implementation
def clear
@all.clear
end
def << headers
Add a new set of headers to the merged list.
Signature
-
parameter
headers
Headers | Array | Hash
A list of headers to add.
Implementation
def << headers
@all << headers
return self
end
def each(&block)
Enumerate all headers in the merged list.
Signature
-
yields
{|key, value| ...}
The header key and value.
-
parameter
key
String
The header key (lower case).
-
parameter
value
String
The header value.
-
parameter
Implementation
def each(&block)
return to_enum unless block_given?
@all.each do |headers|
headers.each do |key, value|
yield key.to_s.downcase, value.to_s
end
end
end