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 41 |
# 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 @content = 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
77 78 79 80 |
# File 'lib/soap/attachment.rb', line 77 def self.contentid(obj) # this needs to be fixed [obj.__id__.to_s, Process.pid.to_s].join('.') end |
.mime_contentid(obj) ⇒ Object
82 83 84 |
# File 'lib/soap/attachment.rb', line 82 def self.mime_contentid(obj) '<' + contentid(obj) + '>' end |
Instance Method Details
#content ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/soap/attachment.rb', line 55 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
43 44 45 |
# File 'lib/soap/attachment.rb', line 43 def contentid @contentid ||= Attachment.contentid(self) end |
#contentid=(contentid) ⇒ Object
47 48 49 |
# File 'lib/soap/attachment.rb', line 47 def contentid=(contentid) @contentid = contentid end |
#mime_contentid ⇒ Object
51 52 53 |
# File 'lib/soap/attachment.rb', line 51 def mime_contentid '<' + contentid + '>' end |
#save(filename) ⇒ Object
71 72 73 74 75 |
# File 'lib/soap/attachment.rb', line 71 def save(filename) File.open(filename, "wb") do |f| write(f) end end |
#to_s ⇒ Object
63 64 65 |
# File 'lib/soap/attachment.rb', line 63 def to_s content end |
#write(out) ⇒ Object
67 68 69 |
# File 'lib/soap/attachment.rb', line 67 def write(out) out.write(content) end |