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.



314
315
316
# File 'lib/protocol/http/headers.rb', line 314

def initialize(*all)
	@all = all
end

Instance Method Details

#<<(headers) ⇒ Object



330
331
332
333
334
# File 'lib/protocol/http/headers.rb', line 330

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

#clearObject



326
327
328
# File 'lib/protocol/http/headers.rb', line 326

def clear
	@all.clear
end

#each(&block) ⇒ Object



337
338
339
340
341
342
343
344
345
# File 'lib/protocol/http/headers.rb', line 337

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

#fieldsObject



318
319
320
# File 'lib/protocol/http/headers.rb', line 318

def fields
	each.to_a
end

#flattenObject



322
323
324
# File 'lib/protocol/http/headers.rb', line 322

def flatten
	Headers.new(fields)
end