class MIME::Header

Header section for Internet and MIME messages.

Public Class Methods

new() click to toggle source
# File lib/mime/header.rb, line 8
def initialize
  @headers = Hash.new
end

Public Instance Methods

delete(name) click to toggle source

Delete header associated with name.

# File lib/mime/header.rb, line 43
def delete name
  @headers.delete_if {|k,v| name.downcase == k.downcase }
end
get(name) click to toggle source

Get header value associated with name.

# File lib/mime/header.rb, line 26
def get name
  _, value = @headers.find {|k,v| name.downcase == k.downcase }
  value
end
set(name, value) click to toggle source

Set header name to value. If a header of the same name exists it will be overwritten. Header names are case-insensitive.

# File lib/mime/header.rb, line 35
def set name, value
  delete(name)
  @headers.store(name, value) unless value.nil?
end
to_s() click to toggle source

Convert all headers to their string equivalents and join them using the RFC 2822 CRLF line separator.

# File lib/mime/header.rb, line 19
def to_s
  @headers.to_a.map {|kv| kv.join(": ")}.join("\r\n")
end