Class: Railgun::Attachment
- Inherits:
-
StringIO
- Object
- StringIO
- Railgun::Attachment
- Defined in:
- lib/railgun/attachment.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#original_filename ⇒ Object
readonly
Returns the value of attribute original_filename.
-
#overwritten_filename ⇒ Object
readonly
Returns the value of attribute overwritten_filename.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #attach_to_message!(mb) ⇒ Object
-
#initialize(attachment, *args) ⇒ Attachment
constructor
A new instance of Attachment.
- #inline? ⇒ Boolean
- #is_original_filename ⇒ Object
- #source_filename ⇒ Object
Constructor Details
#initialize(attachment, *args) ⇒ Attachment
Returns a new instance of Attachment.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/railgun/attachment.rb', line 8 def initialize(, *args) @path = '' @inline = args.detect { |opt| opt[:inline] } if @inline @filename = .cid else @filename = .filename end @original_filename = @filename if args.detect { |opt| opt[:filename] } @filename = opt[:filename] end @overwritten_filename = @filename @content_type = .content_type.split(';')[0] super .body.decoded end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
5 6 7 |
# File 'lib/railgun/attachment.rb', line 5 def content_type @content_type end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
5 6 7 |
# File 'lib/railgun/attachment.rb', line 5 def filename @filename end |
#original_filename ⇒ Object (readonly)
Returns the value of attribute original_filename.
5 6 7 |
# File 'lib/railgun/attachment.rb', line 5 def original_filename @original_filename end |
#overwritten_filename ⇒ Object (readonly)
Returns the value of attribute overwritten_filename.
5 6 7 |
# File 'lib/railgun/attachment.rb', line 5 def overwritten_filename @overwritten_filename end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/railgun/attachment.rb', line 5 def path @path end |
Instance Method Details
#attach_to_message!(mb) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/railgun/attachment.rb', line 43 def (mb) if mb.nil? nil end if inline? mb.add_inline_image self, @filename else mb. self, @filename end end |
#inline? ⇒ Boolean
31 32 33 |
# File 'lib/railgun/attachment.rb', line 31 def inline? @inline end |
#is_original_filename ⇒ Object
35 36 37 |
# File 'lib/railgun/attachment.rb', line 35 def is_original_filename @original_filename == @overwritten_filename end |
#source_filename ⇒ Object
39 40 41 |
# File 'lib/railgun/attachment.rb', line 39 def source_filename @filename end |