Class: ConvertApi::Result

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Result

Returns a new instance of Result.



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

def initialize(response)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'lib/convert_api/result.rb', line 3

def response
  @response
end

Instance Method Details

#conversion_costObject



9
10
11
# File 'lib/convert_api/result.rb', line 9

def conversion_cost
  response['ConversionCost']
end

#fileObject



13
14
15
# File 'lib/convert_api/result.rb', line 13

def file
  files.first
end

#filesObject



17
18
19
# File 'lib/convert_api/result.rb', line 17

def files
  @files ||= response['Files'].map{ |file_info| ResultFile.new(file_info) }
end

#save_files(path) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/convert_api/result.rb', line 25

def save_files(path)
  threads = files.map do |file|
    Thread.new { file.save(path) }
  end

  threads.map(&:value)
end

#urlsObject



21
22
23
# File 'lib/convert_api/result.rb', line 21

def urls
  files.map(&:url)
end