Class: Protocol::HTTP::Headers::Merged

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/protocol/http/headers.rb

Overview

Used for merging objects into a sequential list of headers. Normalizes header keys and values.

Instance Method Summary collapse

Constructor Details

#initialize(*all) ⇒ Merged

Returns a new instance of Merged.



233
234
235
# File 'lib/protocol/http/headers.rb', line 233

def initialize(*all)
  @all = all
end

Instance Method Details

#<<(headers) ⇒ Object



241
242
243
244
245
# File 'lib/protocol/http/headers.rb', line 241

def << headers
  @all << headers
  
  return self
end

#clearObject



237
238
239
# File 'lib/protocol/http/headers.rb', line 237

def clear
  @all.clear
end

#each {|String, String| ... } ⇒ Object

Yields:

  • (String, String)

    header key (lower case) and value (as string).



248
249
250
251
252
253
254
# File 'lib/protocol/http/headers.rb', line 248

def each(&block)
  @all.each do |headers|
    headers.each do |key, value|
      yield key.downcase, value.to_s
    end
  end
end