Class: OpenRosa::Submission::Attachment

Inherits:
Object
  • Object
show all
Defined in:
lib/open_rosa/submission.rb

Overview

Represents an uploaded file attachment

Instance Attribute Summary collapse

Instance Method Summary collapse

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_typeObject (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

#filenameObject (readonly)

Returns the value of attribute filename.



174
175
176
# File 'lib/open_rosa/submission.rb', line 174

def filename
  @filename
end

#sizeObject (readonly)

Returns the value of attribute size.



174
175
176
# File 'lib/open_rosa/submission.rb', line 174

def size
  @size
end

#tempfileObject (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

#pathObject

Get the file path (useful for moving/copying)



190
191
192
# File 'lib/open_rosa/submission.rb', line 190

def path
  tempfile.path
end

#readObject

Read the file contents



184
185
186
187
# File 'lib/open_rosa/submission.rb', line 184

def read
  tempfile.rewind
  tempfile.read
end