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.



113
114
115
116
117
118
# File 'lib/soap/mimemessage.rb', line 113

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.



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

def body
  @body
end

#headersObject

Returns the value of attribute headers.



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

def headers
  @headers
end

Class Method Details

.parse(str) ⇒ Object



120
121
122
# File 'lib/soap/mimemessage.rb', line 120

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

Instance Method Details

#contentidObject



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

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



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

def parse(str)
  headers, body = str.split(/\r\n\r\n/, 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



145
146
147
# File 'lib/soap/mimemessage.rb', line 145

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