Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • soap/mimemessage.rb

Class/Module Index [+]

Quicksearch

SOAP::MIMEMessage::Headers

Public Class Methods

parse(str) click to toggle source
 
               # File soap/mimemessage.rb, line 46
def self.parse(str)
  new.parse(str)
end
            

Public Instance Methods

add(key, value) click to toggle source
 
               # File soap/mimemessage.rb, line 93
def add(key, value)
  if key != nil and value != nil
    header = parse_rhs(value)
    header.key = key
    self[key.downcase] = header
  end
end
            
parse(str) click to toggle source
 
               # File soap/mimemessage.rb, line 50
def parse(str)
  header_cache = nil
  str.each do |line|
    case line
    when /^\A[^\: \t]+:\s*.+$/
      parse_line(header_cache) if header_cache
      header_cache = line.sub(/\r?\n\z/, '')
    when /^\A\s+(.*)$/
      # a continuous line at the beginning line crashes here.
      header_cache << line
    else
      raise RuntimeError.new("unexpected header: #{line.inspect}")
    end
  end
  parse_line(header_cache) if header_cache
  self
end
            
parse_line(line) click to toggle source
 
               # File soap/mimemessage.rb, line 68
def parse_line(line)
  if /^\A([^\: \t]+):\s*(.+)\z/ =~ line
    header = parse_rhs($2.strip)
    header.key = $1.strip
    self[header.key.downcase] = header
  else
    raise RuntimeError.new("unexpected header line: #{line.inspect}")
  end
end
            
parse_rhs(str) click to toggle source
 
               # File soap/mimemessage.rb, line 78
def parse_rhs(str)
  a = str.split(/;+\s+/)
  header = Header.new
  header.str = str
  header.root = a.shift
  a.each do |pair|
    if pair =~ /(\w+)\s*=\s*"?([^"]+)"?/
      header[$1.downcase] = $2
    else
      raise RuntimeError.new("unexpected header component: #{pair.inspect}")
    end
  end
  header
end
            
to_s() click to toggle source
 
               # File soap/mimemessage.rb, line 101
def to_s
  self.values.collect { |hdr|
    hdr.to_s
  }.join("\r\n")
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus