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.



75
76
77
# File 'lib/dolzenko/remote_download.rb', line 75

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

Instance Attribute Details

#content_typeObject

Returns the value of attribute content_type.



89
90
91
# File 'lib/dolzenko/remote_download.rb', line 89

def content_type
  @content_type
end

#filenameObject

Returns the value of attribute filename.



89
90
91
# File 'lib/dolzenko/remote_download.rb', line 89

def filename
  @filename
end

#original_filenameObject

Returns the value of attribute original_filename.



89
90
91
# File 'lib/dolzenko/remote_download.rb', line 89

def original_filename
  @original_filename
end

#sizeObject

Returns the value of attribute size.



89
90
91
# File 'lib/dolzenko/remote_download.rb', line 89

def size
  @size
end

Class Method Details

.from_http_response(response, request_url) ⇒ Object

Constructs IO object from HTTPResponse



80
81
82
83
84
85
86
87
# File 'lib/dolzenko/remote_download.rb', line 80

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