Class: Paperclip::StringioAdapter
- Inherits:
-
Object
- Object
- Paperclip::StringioAdapter
- Defined in:
- lib/paperclip/io_adapters/stringio_adapter.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #eof? ⇒ Boolean
- #fingerprint ⇒ Object
-
#initialize(target) ⇒ StringioAdapter
constructor
A new instance of StringioAdapter.
- #path ⇒ Object
- #read(length = nil, buffer = nil) ⇒ Object
-
#rewind ⇒ Object
We don’t use this directly, but aws/sdk does.
- #size ⇒ Object
Constructor Details
#initialize(target) ⇒ StringioAdapter
Returns a new instance of StringioAdapter.
3 4 5 6 |
# File 'lib/paperclip/io_adapters/stringio_adapter.rb', line 3 def initialize(target) @target = target @tempfile = copy_to_tempfile(@target) end |
Instance Attribute Details
#content_type ⇒ Object
16 17 18 19 20 |
# File 'lib/paperclip/io_adapters/stringio_adapter.rb', line 16 def content_type @content_type ||= @target.content_type if @target.respond_to?(:content_type) @content_type ||= "text/plain" @content_type end |
#original_filename ⇒ Object
10 11 12 13 14 |
# File 'lib/paperclip/io_adapters/stringio_adapter.rb', line 10 def original_filename @original_filename ||= @target.original_filename if @target.respond_to?(:original_filename) @original_filename ||= "stringio.txt" @original_filename.strip end |
Instance Method Details
#eof? ⇒ Boolean
39 40 41 |
# File 'lib/paperclip/io_adapters/stringio_adapter.rb', line 39 def eof? @tempfile.eof? end |
#fingerprint ⇒ Object
26 27 28 |
# File 'lib/paperclip/io_adapters/stringio_adapter.rb', line 26 def fingerprint Digest::MD5.hexdigest(read) end |
#path ⇒ Object
43 44 45 |
# File 'lib/paperclip/io_adapters/stringio_adapter.rb', line 43 def path @tempfile.path end |
#read(length = nil, buffer = nil) ⇒ Object
30 31 32 |
# File 'lib/paperclip/io_adapters/stringio_adapter.rb', line 30 def read(length = nil, buffer = nil) @tempfile.read(length, buffer) end |
#rewind ⇒ Object
We don’t use this directly, but aws/sdk does.
35 36 37 |
# File 'lib/paperclip/io_adapters/stringio_adapter.rb', line 35 def rewind @tempfile.rewind end |
#size ⇒ Object
22 23 24 |
# File 'lib/paperclip/io_adapters/stringio_adapter.rb', line 22 def size @target.size end |