Sha256: 8b1f8db7f944f01f9037b59e5b53996ec582a2328cfe4c20f0501a067a732906
Contents?: true
Size: 782 Bytes
Versions: 7
Compression:
Stored size: 782 Bytes
Contents
require 'open-uri' module ConvertApi class ResultFile attr_reader :info def initialize(info) @info = info end def url info['Url'] end def filename info['FileName'] end def size info['FileSize'] end def io @io ||= open(url, download_options) end def save(path) path = File.join(path, filename) if File.directory?(path) IO.copy_stream(io, path, size) path end private def download_options options = { read_timeout: config.download_timeout } options[:open_timeout] = config.connect_timeout if RUBY_VERSION > '2.2.0' options.merge('User-Agent' => ConvertApi::Client::USER_AGENT) end def config ConvertApi.config end end end
Version data entries
7 entries across 7 versions & 1 rubygems