Class: SOAP::MIMEMessage::Part

Inherits:
Object
  • Object
show all
Defined in:
lib/soap/mimemessage.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePart

Returns a new instance of Part.



111
112
113
114
115
116
# File 'lib/soap/mimemessage.rb', line 111

def initialize
  @headers = Headers.new
  @headers.add("Content-Transfer-Encoding", "8bit")
  @body = nil
  @contentid = nil
end

Instance Attribute Details

#bodyObject Also known as: content

Returns the value of attribute body.



109
110
111
# File 'lib/soap/mimemessage.rb', line 109

def body
  @body
end

#headersObject

Returns the value of attribute headers.



109
110
111
# File 'lib/soap/mimemessage.rb', line 109

def headers
  @headers
end

Class Method Details

.parse(str) ⇒ Object



118
119
120
# File 'lib/soap/mimemessage.rb', line 118

def self.parse(str)
  new.parse(str)
end

Instance Method Details

#contentidObject



133
134
135
136
137
138
139
# File 'lib/soap/mimemessage.rb', line 133

def contentid
  if @contentid == nil and @headers.key?('content-id')
	@contentid = @headers['content-id'].str
	@contentid = $1 if @contentid =~ /^<(.+)>$/
  end
  @contentid
end

#parse(str) ⇒ Object



122
123
124
125
126
127
128
129
130
131
# File 'lib/soap/mimemessage.rb', line 122

def parse(str)
  headers, body = str.split(/\r\n\r\n/s, 2)
  if headers != nil and body != nil
	@headers = Headers.parse(headers)
	@body = body.sub(/\r\n\z/, '')
  else
	raise RuntimeError.new("unexpected part: #{str.inspect}")
  end
  self
end

#to_sObject



143
144
145
# File 'lib/soap/mimemessage.rb', line 143

def to_s
  @headers.to_s + "\r\n\r\n" + @body
end