class ConvertApi::ResultFile

Attributes

info[R]

Public Class Methods

new(info) click to toggle source
# File lib/convert_api/result_file.rb, line 7
def initialize(info)
  @info = info
end

Public Instance Methods

filename() click to toggle source
# File lib/convert_api/result_file.rb, line 15
def filename
  info['FileName']
end
io() click to toggle source
# File lib/convert_api/result_file.rb, line 23
def io
  @io ||= URI.parse(url).open(download_options)
end
save(path) click to toggle source
# File lib/convert_api/result_file.rb, line 27
def save(path)
  path = File.join(path, filename) if File.directory?(path)

  IO.copy_stream(io, path, size)

  path
end
size() click to toggle source
# File lib/convert_api/result_file.rb, line 19
def size
  info['FileSize']
end
url() click to toggle source
# File lib/convert_api/result_file.rb, line 11
def url
  info['Url']
end

Private Instance Methods

config() click to toggle source
# File lib/convert_api/result_file.rb, line 45
def config
  ConvertApi.config
end
download_options() click to toggle source
# File lib/convert_api/result_file.rb, line 37
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