Class: SOAP::Attachment
Instance Attribute Summary collapse
-
#contenttype ⇒ Object
Returns the value of attribute contenttype.
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Class Method Summary collapse
Instance Method Summary collapse
- #content ⇒ Object
- #contentid ⇒ Object
- #contentid=(contentid) ⇒ Object
-
#initialize(string_or_readable = nil) ⇒ Attachment
constructor
A new instance of Attachment.
- #mime_contentid ⇒ Object
- #save(filename) ⇒ Object
- #to_s ⇒ Object
- #write(out) ⇒ Object
Constructor Details
#initialize(string_or_readable = nil) ⇒ Attachment
Returns a new instance of Attachment.
36 37 38 39 40 |
# File 'lib/soap/attachment.rb', line 36 def initialize(string_or_readable = nil) @string_or_readable = string_or_readable @contenttype = "application/octet-stream" @contentid = nil end |
Instance Attribute Details
#contenttype ⇒ Object
Returns the value of attribute contenttype
34 35 36 |
# File 'lib/soap/attachment.rb', line 34 def contenttype @contenttype end |
#io ⇒ Object (readonly)
Returns the value of attribute io
33 34 35 |
# File 'lib/soap/attachment.rb', line 33 def io @io end |
Class Method Details
.contentid(obj) ⇒ Object
76 77 78 79 |
# File 'lib/soap/attachment.rb', line 76 def self.contentid(obj) # this needs to be fixed [obj.__id__.to_s, Process.pid.to_s].join('.') end |
.mime_contentid(obj) ⇒ Object
81 82 83 |
# File 'lib/soap/attachment.rb', line 81 def self.mime_contentid(obj) '<' + contentid(obj) + '>' end |
Instance Method Details
#content ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/soap/attachment.rb', line 54 def content if @content == nil and @string_or_readable != nil @content = @string_or_readable.respond_to?(:read) ? @string_or_readable.read : @string_or_readable end @content end |
#contentid ⇒ Object
42 43 44 |
# File 'lib/soap/attachment.rb', line 42 def contentid @contentid ||= Attachment.contentid(self) end |
#contentid=(contentid) ⇒ Object
46 47 48 |
# File 'lib/soap/attachment.rb', line 46 def contentid=(contentid) @contentid = contentid end |
#mime_contentid ⇒ Object
50 51 52 |
# File 'lib/soap/attachment.rb', line 50 def mime_contentid '<' + contentid + '>' end |
#save(filename) ⇒ Object
70 71 72 73 74 |
# File 'lib/soap/attachment.rb', line 70 def save(filename) File.open(filename, "wb") do |f| write(f) end end |
#to_s ⇒ Object
62 63 64 |
# File 'lib/soap/attachment.rb', line 62 def to_s content end |
#write(out) ⇒ Object
66 67 68 |
# File 'lib/soap/attachment.rb', line 66 def write(out) out.write(content) end |