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!(m_body) ⇒ Object
-
#initialize(attachment, *args) ⇒ Attachment
constructor
A new instance of Attachment.
- #inline? ⇒ Boolean
- #original_filename? ⇒ Boolean
- #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 |
# File 'lib/railgun/attachment.rb', line 8 def initialize(, *args) @path = '' @inline = args.detect { |opt| opt[:inline] } @filename = if @inline .cid else .filename end @original_filename = @filename @filename = opt[:filename] if args.detect { |opt| opt[:filename] } @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!(m_body) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/railgun/attachment.rb', line 41 def (m_body) if inline? m_body.add_inline_image self, @filename else m_body. self, @filename end end |
#inline? ⇒ Boolean
29 30 31 |
# File 'lib/railgun/attachment.rb', line 29 def inline? @inline end |
#original_filename? ⇒ Boolean
33 34 35 |
# File 'lib/railgun/attachment.rb', line 33 def original_filename? @original_filename == @overwritten_filename end |
#source_filename ⇒ Object
37 38 39 |
# File 'lib/railgun/attachment.rb', line 37 def source_filename @filename end |