Class: Astrotrain::Message::Attachment
- Inherits:
-
Object
- Object
- Astrotrain::Message::Attachment
- Defined in:
- lib/astrotrain/message.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #attached? ⇒ Boolean
-
#close ⇒ Object
For IO API compatibility when used with Rest-Client.
- #content_type ⇒ Object
- #data ⇒ Object
- #filename ⇒ Object (also: #path)
-
#initialize(part) ⇒ Attachment
constructor
A new instance of Attachment.
- #inspect ⇒ Object
- #read(value = nil) ⇒ Object
- #read? ⇒ Boolean
Constructor Details
#initialize(part) ⇒ Attachment
Returns a new instance of Attachment.
232 233 234 235 |
# File 'lib/astrotrain/message.rb', line 232 def initialize(part) @part = part @is_read = false end |
Instance Method Details
#==(other) ⇒ Object
272 273 274 |
# File 'lib/astrotrain/message.rb', line 272 def ==(other) super || (filename == other.filename && content_type == other.content_type) end |
#attached? ⇒ Boolean
268 269 270 |
# File 'lib/astrotrain/message.rb', line 268 def attached? !filename.nil? end |
#close ⇒ Object
For IO API compatibility when used with Rest-Client
246 247 |
# File 'lib/astrotrain/message.rb', line 246 def close end |
#content_type ⇒ Object
237 238 239 |
# File 'lib/astrotrain/message.rb', line 237 def content_type @part.content_type end |
#data ⇒ Object
264 265 266 |
# File 'lib/astrotrain/message.rb', line 264 def data @part.body end |
#filename ⇒ Object Also known as: path
241 242 243 |
# File 'lib/astrotrain/message.rb', line 241 def filename @filename ||= @part.type_param("name") || @part.disposition_param('filename') end |
#inspect ⇒ Object
276 277 278 |
# File 'lib/astrotrain/message.rb', line 276 def inspect %(#<Message::Attachment filename=#{filename.inspect} content_type=#{content_type.inspect}>) end |
#read(value = nil) ⇒ Object
251 252 253 254 255 256 257 258 |
# File 'lib/astrotrain/message.rb', line 251 def read(value = nil) if read? nil else @is_read = true data end end |
#read? ⇒ Boolean
260 261 262 |
# File 'lib/astrotrain/message.rb', line 260 def read? @is_read == true end |