Class: ConvertApi::ResultFile

Inherits:
Object
  • Object
show all
Defined in:
lib/convert_api/result_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(info) ⇒ ResultFile

Returns a new instance of ResultFile.



7
8
9
# File 'lib/convert_api/result_file.rb', line 7

def initialize(info)
  @info = info
end

Instance Attribute Details

#infoObject (readonly)

Returns the value of attribute info.



5
6
7
# File 'lib/convert_api/result_file.rb', line 5

def info
  @info
end

Instance Method Details

#filenameObject



15
16
17
# File 'lib/convert_api/result_file.rb', line 15

def filename
  info['FileName']
end

#ioObject



23
24
25
# File 'lib/convert_api/result_file.rb', line 23

def io
  @io ||= URI.parse(url).open(download_options)
end

#save(path) ⇒ Object



27
28
29
30
31
32
33
# 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

#sizeObject



19
20
21
# File 'lib/convert_api/result_file.rb', line 19

def size
  info['FileSize']
end

#urlObject



11
12
13
# File 'lib/convert_api/result_file.rb', line 11

def url
  info['Url']
end