Class: Shrine::DataFile

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/shrine/plugins/data_uri.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, content_type: nil, filename: nil) ⇒ DataFile

Returns a new instance of DataFile.


159
160
161
162
163
# File 'lib/shrine/plugins/data_uri.rb', line 159

def initialize(content, content_type: nil, filename: nil)
  @content_type      = content_type
  @original_filename = filename
  @io                = StringIO.new(content)
end

Instance Attribute Details

#content_typeObject (readonly)

Returns the value of attribute content_type.


157
158
159
# File 'lib/shrine/plugins/data_uri.rb', line 157

def content_type
  @content_type
end

#original_filenameObject (readonly)

Returns the value of attribute original_filename.


157
158
159
# File 'lib/shrine/plugins/data_uri.rb', line 157

def original_filename
  @original_filename
end

Instance Method Details

#closeObject


172
173
174
175
# File 'lib/shrine/plugins/data_uri.rb', line 172

def close
  @io.close
  @io.string.clear # deallocate string
end

#to_ioObject


165
166
167
# File 'lib/shrine/plugins/data_uri.rb', line 165

def to_io
  @io
end