Class: ConvertApi::Result
- Inherits:
-
Object
- Object
- ConvertApi::Result
- Defined in:
- lib/convert_api/result.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #conversion_cost ⇒ Object
- #file ⇒ Object
- #files ⇒ Object
-
#initialize(response) ⇒ Result
constructor
A new instance of Result.
- #save_files(path) ⇒ Object
- #urls ⇒ Object
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
#response ⇒ Object (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_cost ⇒ Object
9 10 11 |
# File 'lib/convert_api/result.rb', line 9 def conversion_cost response['ConversionCost'] end |
#file ⇒ Object
13 14 15 |
# File 'lib/convert_api/result.rb', line 13 def file files.first end |
#files ⇒ Object
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 |
#urls ⇒ Object
21 22 23 |
# File 'lib/convert_api/result.rb', line 21 def urls files.map(&:url) end |