Class: K8::UploadedFile
- Inherits:
-
Object
- Object
- K8::UploadedFile
- Defined in:
- lib/keight.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.
-
#tmp_filepath ⇒ Object
readonly
Returns the value of attribute tmp_filepath.
Instance Method Summary collapse
- #clean ⇒ Object
-
#initialize(filename, content_type) ⇒ UploadedFile
constructor
A new instance of UploadedFile.
Constructor Details
#initialize(filename, content_type) ⇒ UploadedFile
Returns a new instance of UploadedFile.
380 381 382 383 384 385 386 387 388 |
# File 'lib/keight.rb', line 380 def initialize(filename, content_type) #; [!ityxj] takes filename and content type. @filename = filename @content_type = content_type #; [!5c8w6] sets temporary filepath with random string. @tmp_filepath = new_filepath() #; [!8ezhr] yields with opened temporary file. File.open(@tmp_filepath, 'wb') {|f| yield f } if block_given? end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
390 391 392 |
# File 'lib/keight.rb', line 390 def content_type @content_type end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
390 391 392 |
# File 'lib/keight.rb', line 390 def filename @filename end |
#tmp_filepath ⇒ Object (readonly)
Returns the value of attribute tmp_filepath.
390 391 392 |
# File 'lib/keight.rb', line 390 def tmp_filepath @tmp_filepath end |
Instance Method Details
#clean ⇒ Object
392 393 394 395 396 397 |
# File 'lib/keight.rb', line 392 def clean #; [!ft454] removes temporary file if exists. File.unlink(@tmp_filepath) if @tmp_filepath rescue SystemCallError # or Errno::ENOENT? nil end |