lib/groupdocs/document.rb in groupdocs-0.2.4 vs lib/groupdocs/document.rb in groupdocs-0.2.5
- old
+ new
@@ -52,14 +52,38 @@
# @attr [GroupDocs::Storage::File] file
attr_accessor :file
# @attr [Time] process_date
attr_accessor :process_date
- # @attr [Array] outputs
+ # @attr [Array<GroupDocs::Storage::File>] outputs
attr_accessor :outputs
+ # @attr [Array<Symbol>] output_formats
+ attr_accessor :output_formats
#
+ # Coverts passed array of attributes hash to array of GroupDocs::Storage::File.
+ #
+ # @param [Array<Hash>] outputs Array of file attributes hashes
+ #
+ def outputs=(outputs)
+ if outputs
+ @outputs = outputs.map do |output|
+ GroupDocs::Storage::File.new(output)
+ end
+ end
+ end
+
+ #
+ # Returns output formats in human-readable format.
+ #
+ # @return [Array<Symbol>]
+ #
+ def output_formats
+ @output_formats.split(?;).map(&:to_sym)
+ end
+
+ #
# Converts timestamp which is return by API server to Time object.
#
# @return [Time]
#
def process_date
@@ -258,10 +282,18 @@
end
#
# Converts document to given format.
#
+ # @example
+ # document = GroupDocs::Document.find!(:name, 'CV.doc')
+ # job = document.convert!(:docx)
+ # sleep(5) # wait for server to finish converting
+ # original_document = job.documents!.first
+ # converted_file = original_file.outputs.first
+ # converted_file.download!(File.dirname(__FILE__))
+ #
# @param [Symbol] format
# @param [Hash] options
# @option options [Boolean] :email_results Set to true if converted document should be emailed
# @param [Hash] access Access credentials
# @option access [String] :client_id
@@ -272,11 +304,11 @@
options.merge!(new_type: format)
api = Api::Request.new do |request|
request[:access] = access
request[:method] = :POST
- request[:path] = "/{{client_id}}/files/#{file.guid}"
+ request[:path] = "/async/{{client_id}}/files/#{file.guid}"
end
api.add_params(options)
json = api.execute!
Job.new(id: json[:job_id])
@@ -472,9 +504,10 @@
#
# @example
# document_one = GroupDocs::Document.find!(:name, 'CV.doc')
# document_two = GroupDocs::Document.find!(:name, 'Resume.doc')
# job = document_one.compare!(document_two)
+ # sleep(5) # wait for server to finish comparing
# result = job.documents!.first
# result.changes!
#
# @param [Hash] access Access credentials
# @option access [String] :client_id