Class: OpenRosa::Submission::Attachment
- Inherits:
-
Object
- Object
- OpenRosa::Submission::Attachment
- Defined in:
- lib/open_rosa/submission.rb
Overview
Represents an uploaded file attachment
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#tempfile ⇒ Object
readonly
Returns the value of attribute tempfile.
Instance Method Summary collapse
-
#initialize(filename:, content_type:, size:, tempfile:) ⇒ Attachment
constructor
A new instance of Attachment.
-
#path ⇒ Object
Get the file path (useful for moving/copying).
-
#read ⇒ Object
Read the file contents.
Constructor Details
#initialize(filename:, content_type:, size:, tempfile:) ⇒ Attachment
Returns a new instance of Attachment.
176 177 178 179 180 181 |
# File 'lib/open_rosa/submission.rb', line 176 def initialize(filename:, content_type:, size:, tempfile:) @filename = filename @content_type = content_type @size = size @tempfile = tempfile end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
174 175 176 |
# File 'lib/open_rosa/submission.rb', line 174 def content_type @content_type end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
174 175 176 |
# File 'lib/open_rosa/submission.rb', line 174 def filename @filename end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
174 175 176 |
# File 'lib/open_rosa/submission.rb', line 174 def size @size end |
#tempfile ⇒ Object (readonly)
Returns the value of attribute tempfile.
174 175 176 |
# File 'lib/open_rosa/submission.rb', line 174 def tempfile @tempfile end |
Instance Method Details
#path ⇒ Object
Get the file path (useful for moving/copying)
190 191 192 |
# File 'lib/open_rosa/submission.rb', line 190 def path tempfile.path end |
#read ⇒ Object
Read the file contents
184 185 186 187 |
# File 'lib/open_rosa/submission.rb', line 184 def read tempfile.rewind tempfile.read end |