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.
37 38 39 40 41 42 |
# File 'lib/soap/attachment.rb', line 37 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.
35 36 37 |
# File 'lib/soap/attachment.rb', line 35 def contenttype @contenttype end |
#io ⇒ Object (readonly)
Returns the value of attribute io.
34 35 36 |
# File 'lib/soap/attachment.rb', line 34 def io @io end |
Class Method Details
.contentid(obj) ⇒ Object
78 79 80 81 |
# File 'lib/soap/attachment.rb', line 78 def self.contentid(obj) # this needs to be fixed [obj.__id__.to_s, Process.pid.to_s].join('.') end |
.mime_contentid(obj) ⇒ Object
83 84 85 |
# File 'lib/soap/attachment.rb', line 83 def self.mime_contentid(obj) '<' + contentid(obj) + '>' end |
Instance Method Details
#content ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/soap/attachment.rb', line 56 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
44 45 46 |
# File 'lib/soap/attachment.rb', line 44 def contentid @contentid ||= Attachment.contentid(self) end |
#contentid=(contentid) ⇒ Object
48 49 50 |
# File 'lib/soap/attachment.rb', line 48 def contentid=(contentid) @contentid = contentid end |
#mime_contentid ⇒ Object
52 53 54 |
# File 'lib/soap/attachment.rb', line 52 def mime_contentid '<' + contentid + '>' end |
#save(filename) ⇒ Object
72 73 74 75 76 |
# File 'lib/soap/attachment.rb', line 72 def save(filename) File.open(filename, "wb") do |f| write(f) end end |
#to_s ⇒ Object
64 65 66 |
# File 'lib/soap/attachment.rb', line 64 def to_s content end |
#write(out) ⇒ Object
68 69 70 |
# File 'lib/soap/attachment.rb', line 68 def write(out) out.write(content) end |