Class: Dolzenko::RemoteDownload::MyStringIO

Inherits:
StringIO
  • Object
show all
Defined in:
lib/dolzenko/remote_download.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ MyStringIO

Returns a new instance of MyStringIO.



78
79
80
# File 'lib/dolzenko/remote_download.rb', line 78

def initialize(*args)
  super(*args)
end

Instance Attribute Details

#content_typeObject

Returns the value of attribute content_type.



92
93
94
# File 'lib/dolzenko/remote_download.rb', line 92

def content_type
  @content_type
end

#filenameObject

Returns the value of attribute filename.



92
93
94
# File 'lib/dolzenko/remote_download.rb', line 92

def filename
  @filename
end

#original_filenameObject

Returns the value of attribute original_filename.



92
93
94
# File 'lib/dolzenko/remote_download.rb', line 92

def original_filename
  @original_filename
end

#sizeObject

Returns the value of attribute size.



92
93
94
# File 'lib/dolzenko/remote_download.rb', line 92

def size
  @size
end

Class Method Details

.from_http_response(response, request_url) ⇒ Object

Constructs IO object from HTTPResponse



83
84
85
86
87
88
89
90
# File 'lib/dolzenko/remote_download.rb', line 83

def self.from_http_response(response, request_url)
  new(response.body).tap do |io|
    io.size = response.body.size
    io.content_type = response['content-type']
    io.filename = File.basename(request_url)
    io.original_filename = File.basename(request_url)
  end
end