Class: Sunrise::FileUpload::Http::UploadedFile

Inherits:
Object
  • Object
show all
Defined in:
lib/sunrise/file_upload/http.rb

Overview

Create file from hash

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ UploadedFile

Returns a new instance of UploadedFile.

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
# File 'lib/sunrise/file_upload/http.rb', line 12

def initialize(hash)
  @original_filename = hash[:filename]
  @content_type      = hash[:type]
  @headers           = hash[:head]
  @tempfile          = hash[:tempfile]
  raise(ArgumentError, ':tempfile is required') unless @tempfile
end

Instance Attribute Details

#content_typeObject

Returns the value of attribute content_type.



10
11
12
# File 'lib/sunrise/file_upload/http.rb', line 10

def content_type
  @content_type
end

#headersObject

Returns the value of attribute headers.



10
11
12
# File 'lib/sunrise/file_upload/http.rb', line 10

def headers
  @headers
end

#original_filenameObject

Returns the value of attribute original_filename.



10
11
12
# File 'lib/sunrise/file_upload/http.rb', line 10

def original_filename
  @original_filename
end

#tempfileObject

Returns the value of attribute tempfile.



10
11
12
# File 'lib/sunrise/file_upload/http.rb', line 10

def tempfile
  @tempfile
end

Instance Method Details

#openObject



20
21
22
# File 'lib/sunrise/file_upload/http.rb', line 20

def open
  @tempfile.open
end

#pathObject



24
25
26
# File 'lib/sunrise/file_upload/http.rb', line 24

def path
  @tempfile.path
end

#read(*args) ⇒ Object



28
29
30
# File 'lib/sunrise/file_upload/http.rb', line 28

def read(*args)
  @tempfile.read(*args)
end

#rewindObject



32
33
34
# File 'lib/sunrise/file_upload/http.rb', line 32

def rewind
  @tempfile.rewind
end

#sizeObject



36
37
38
# File 'lib/sunrise/file_upload/http.rb', line 36

def size
  @tempfile.size
end