Class: Postmark::Mitt::Attachment

Inherits:
Object
  • Object
show all
Defined in:
lib/postmark/mitt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attachment_source) ⇒ Attachment

Returns a new instance of Attachment.



111
112
113
# File 'lib/postmark/mitt.rb', line 111

def initialize(attachment_source)
  @source = attachment_source
end

Instance Attribute Details

#sourceObject

Returns the value of attribute source.



114
115
116
# File 'lib/postmark/mitt.rb', line 114

def source
  @source
end

Instance Method Details

#content_typeObject



116
117
118
# File 'lib/postmark/mitt.rb', line 116

def content_type
  source["ContentType"]
end

#file_nameObject



120
121
122
# File 'lib/postmark/mitt.rb', line 120

def file_name
  source["Name"]
end

#readObject



124
125
126
127
128
# File 'lib/postmark/mitt.rb', line 124

def read
  tempfile = MittTempfile.new(file_name, content_type)
  tempfile.write(Base64.decode64(source["Content"]))
  tempfile
end

#sizeObject



130
131
132
# File 'lib/postmark/mitt.rb', line 130

def size
  source["ContentLength"]
end