Class: Api2Convert::Result::ConversionResult
- Inherits:
-
Object
- Object
- Api2Convert::Result::ConversionResult
- Defined in:
- lib/api2convert/result.rb
Overview
Instance Attribute Summary collapse
-
#job ⇒ Model::Job
readonly
The completed job.
Instance Method Summary collapse
-
#contents(download_password = nil) ⇒ Object
Download the selected output and return its contents.
-
#download(output_file = nil) ⇒ Object
A FileDownload for a specific output (defaults to the selected one).
-
#initialize(job, transport, index = 0, download_password = nil) ⇒ ConversionResult
constructor
A new instance of ConversionResult.
-
#inspect ⇒ Object
Redacted representation — the remembered download password is masked.
-
#output ⇒ Object
The selected output file (the first one by default).
-
#outputs ⇒ Object
All output files produced by the job.
-
#save(path_or_dir, download_password = nil) ⇒ Object
Download the selected output to disk.
- #to_s ⇒ Object
-
#url ⇒ Object
The download URL of the selected output (self-contained, no auth).
Constructor Details
#initialize(job, transport, index = 0, download_password = nil) ⇒ ConversionResult
Returns a new instance of ConversionResult.
162 163 164 165 166 167 |
# File 'lib/api2convert/result.rb', line 162 def initialize(job, transport, index = 0, download_password = nil) @job = job @transport = transport @index = index @download_password = download_password end |
Instance Attribute Details
#job ⇒ Model::Job (readonly)
Returns the completed job.
160 161 162 |
# File 'lib/api2convert/result.rb', line 160 def job @job end |
Instance Method Details
#contents(download_password = nil) ⇒ Object
Download the selected output and return its contents.
196 197 198 |
# File 'lib/api2convert/result.rb', line 196 def contents(download_password = nil) download.contents(download_password) end |
#download(output_file = nil) ⇒ Object
A FileDownload for a specific output (defaults to the selected one).
201 202 203 |
# File 'lib/api2convert/result.rb', line 201 def download(output_file = nil) FileDownload.new(@transport, output_file.nil? ? output : output_file, @download_password) end |
#inspect ⇒ Object
Redacted representation — the remembered download password is masked.
206 207 208 209 |
# File 'lib/api2convert/result.rb', line 206 def inspect "#<#{self.class.name} job=#{@job.id.inspect} outputs=#{@job.output.length} " \ "download_password=#{Support::Secret.mask(@download_password)}>" end |
#output ⇒ Object
The selected output file (the first one by default).
170 171 172 173 174 175 176 177 178 |
# File 'lib/api2convert/result.rb', line 170 def output # Any index not present — including a negative one — raises rather than # wrapping around. if @index.negative? || @index >= @job.output.length raise Api2Convert::Error, "The job produced no output files." end @job.output[@index] end |
#outputs ⇒ Object
All output files produced by the job.
181 182 183 |
# File 'lib/api2convert/result.rb', line 181 def outputs @job.output end |
#save(path_or_dir, download_password = nil) ⇒ Object
Download the selected output to disk. Returns the path written to.
191 192 193 |
# File 'lib/api2convert/result.rb', line 191 def save(path_or_dir, download_password = nil) download.save(path_or_dir, download_password) end |
#to_s ⇒ Object
211 212 213 |
# File 'lib/api2convert/result.rb', line 211 def to_s inspect end |
#url ⇒ Object
The download URL of the selected output (self-contained, no auth).
186 187 188 |
# File 'lib/api2convert/result.rb', line 186 def url output.uri end |