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.
602 603 604 605 606 607 608 609 610 |
# File 'lib/keight.rb', line 602 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.
612 613 614 |
# File 'lib/keight.rb', line 612 def content_type @content_type end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
612 613 614 |
# File 'lib/keight.rb', line 612 def filename @filename end |
#tmp_filepath ⇒ Object (readonly)
Returns the value of attribute tmp_filepath.
612 613 614 |
# File 'lib/keight.rb', line 612 def tmp_filepath @tmp_filepath end |
Instance Method Details
#clean ⇒ Object
614 615 616 617 618 619 |
# File 'lib/keight.rb', line 614 def clean #; [!ft454] removes temporary file if exists. File.unlink(@tmp_filepath) if @tmp_filepath rescue SystemCallError # or Errno::ENOENT? nil end |