Class: Sandals::UploadedFile
- Inherits:
-
Object
- Object
- Sandals::UploadedFile
- Defined in:
- lib/sandals/uploaded_file.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
-
#initialize(name:, content_type:, content:) ⇒ UploadedFile
constructor
A new instance of UploadedFile.
- #read ⇒ Object
Constructor Details
#initialize(name:, content_type:, content:) ⇒ UploadedFile
Returns a new instance of UploadedFile.
7 8 9 10 11 12 |
# File 'lib/sandals/uploaded_file.rb', line 7 def initialize(name:, content_type:, content:) @name = File.basename(name.to_s) @content_type = content_type.to_s @content = content.to_s.b.freeze @size = @content.bytesize end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
5 6 7 |
# File 'lib/sandals/uploaded_file.rb', line 5 def content_type @content_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/sandals/uploaded_file.rb', line 5 def name @name end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
5 6 7 |
# File 'lib/sandals/uploaded_file.rb', line 5 def size @size end |
Instance Method Details
#read ⇒ Object
14 15 16 |
# File 'lib/sandals/uploaded_file.rb', line 14 def read @content.dup end |