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.
219 220 221 222 |
# File 'lib/astrotrain/message.rb', line 219 def initialize(part) @part = part @is_read = false end |
Instance Method Details
#==(other) ⇒ Object
259 260 261 |
# File 'lib/astrotrain/message.rb', line 259 def ==(other) super || (filename == other.filename && content_type == other.content_type) end |
#attached? ⇒ Boolean
255 256 257 |
# File 'lib/astrotrain/message.rb', line 255 def attached? !filename.nil? end |
#close ⇒ Object
For IO API compatibility when used with Rest-Client
233 234 |
# File 'lib/astrotrain/message.rb', line 233 def close end |
#content_type ⇒ Object
224 225 226 |
# File 'lib/astrotrain/message.rb', line 224 def content_type @part.content_type end |
#data ⇒ Object
251 252 253 |
# File 'lib/astrotrain/message.rb', line 251 def data @part.body end |
#filename ⇒ Object Also known as: path
228 229 230 |
# File 'lib/astrotrain/message.rb', line 228 def filename @filename ||= @part.type_param("name") || @part.disposition_param('filename') end |
#inspect ⇒ Object
263 264 265 |
# File 'lib/astrotrain/message.rb', line 263 def inspect %(#<Message::Attachment filename=#{filename.inspect} content_type=#{content_type.inspect}>) end |
#read(value = nil) ⇒ Object
238 239 240 241 242 243 244 245 |
# File 'lib/astrotrain/message.rb', line 238 def read(value = nil) if read? nil else @is_read = true data end end |
#read? ⇒ Boolean
247 248 249 |
# File 'lib/astrotrain/message.rb', line 247 def read? @is_read == true end |