lib/mime/message_content.rb
def write_header_field(name, value, param = {})
        return if name.empty? || value.nil?

        # name and value
        header_field = "#{name}: #{format(value)}"

        # parameters
        param.each do |param_name, param_value|
          # format parameter value
          if param_value.is_a?(Date)
            param_value = param_value.strftime(DATE_TIME_FORMAT)
          else
            param_value = String.new(param_value.to_s)
          end

          # quote parameter value if necessary
          if param_value.start_with?("\"")
            param_value.slice!(0)
            param_value.slice!(-1) if param_value.end_with?("\"")
            quote = true
          else
            quote = param_value.include?(" ") || param_value.include?(";")
          end

          # escape double quote characters
          param_value.sub!("\"", "\\\"")

          if quote
            header_field << "; #{param_name}=\"#{param_value}\""
          else
            header_field << "; #{param_name}=#{param_value}"
          end
        end

        # write header field
        if header_field.length < 79
          puts(header_field)
        else
          fold(header_field)
        end
      end
# Writes the specified header field to the underlying output stream.
#
Writes the specified header field to the underlying output stream.
Writes the specified header field to the underlying output stream .
def write_header_field(name, value, param = {})
        return if name.empty? || value.nil?
        header_field = "#{name}: #{format(value)}"
        param.each do |param_name, param_value|
          if param_value.is_a?(Date)
            param_value = param_value.strftime(DATE_TIME_FORMAT)
          else
            param_value = String.new(param_value.to_s)
          end
          if param_value.start_with?("\"")
            param_value.slice!(0)
            param_value.slice!(-1) if param_value.end_with?("\"")
            quote = true
          else
            quote = param_value.include?(" ") || param_value.include?(";")
          end
          param_value.sub!("\"", "\\\"")
          if quote
            header_field << "; #{param_name}=\"#{param_value}\""
          else
            header_field << "; #{param_name}=#{param_value}"
          end
        end
        if header_field.length < 79
          puts(header_field)
        else
          fold(header_field)
        end
      end
def write_header_field ( name , value , param = { } ) return if name . empty? || value . nil? header_field = "#{name}: #{format(value)}" param . each do | param_name , param_value | if param_value . is_a? ( Date ) param_value = param_value . strftime ( DATE_TIME_FORMAT ) else param_value = String . new ( param_value . to_s ) end if param_value . start_with? ( "\"" ) param_value . slice! ( 0 ) param_value . slice! ( - 1 ) if param_value . end_with? ( "\"" ) quote = true else quote = param_value . include? ( " " ) || param_value . include? ( ";" ) end param_value . sub! ( "\"" , "\\\"" ) if quote header_field << "; #{param_name}=\"#{param_value}\"" else header_field << "; #{param_name}=#{param_value}" end end if header_field . length < 79 puts ( header_field ) else fold ( header_field ) end end
Writes the specified header field to the underlying output stream.
Writes the specified header field to the underlying output stream .
# name and value # parameters # format parameter value # quote parameter value if necessary # escape double quote characters # write header field
name
value
param