Class: Sandals::UploadedFile

Inherits:
Object
  • Object
show all
Defined in:
lib/sandals/uploaded_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/sandals/uploaded_file.rb', line 5

def name
  @name
end

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

#readObject



14
15
16
# File 'lib/sandals/uploaded_file.rb', line 14

def read
  @content.dup
end