Sha256: daefb7c9034a839d1ff0f949b1b844ea57c29a412cb08091182a47c15c4303b7

Contents?: true

Size: 535 Bytes

Versions: 14

Compression:

Stored size: 535 Bytes

Contents

module ConvertApi
  class Result
    attr_reader :response

    def initialize(response)
      @response = response
    end

    def conversion_cost
      response['ConversionCost']
    end

    def file
      files.first
    end

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

    def urls
      files.map(&:url)
    end

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

      threads.map(&:value)
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
convert_api-3.0.0 lib/convert_api/result.rb
convert_api-2.0.0 lib/convert_api/result.rb
convert_api-1.4.0 lib/convert_api/result.rb
convert_api-1.3.2 lib/convert_api/result.rb
convert_api-1.3.1 lib/convert_api/result.rb
convert_api-1.3.0 lib/convert_api/result.rb
convert_api-1.2.1 lib/convert_api/result.rb
convert_api-1.2.0 lib/convert_api/result.rb
convert_api-1.1.0 lib/convert_api/result.rb
convert_api-1.0.4 lib/convert_api/result.rb
convert_api-1.0.3 lib/convert_api/result.rb
convert_api-1.0.2 lib/convert_api/result.rb
convert_api-1.0.1 lib/convert_api/result.rb
convert_api-1.0.0 lib/convert_api/result.rb