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.
131 132 133 134 135 136 |
# File 'lib/api2convert/result.rb', line 131 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.
129 130 131 |
# File 'lib/api2convert/result.rb', line 129 def job @job end |
Instance Method Details
#contents(download_password = nil) ⇒ Object
Download the selected output and return its contents.
165 166 167 |
# File 'lib/api2convert/result.rb', line 165 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).
170 171 172 |
# File 'lib/api2convert/result.rb', line 170 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.
175 176 177 178 |
# File 'lib/api2convert/result.rb', line 175 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).
139 140 141 142 143 144 145 146 147 |
# File 'lib/api2convert/result.rb', line 139 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.
150 151 152 |
# File 'lib/api2convert/result.rb', line 150 def outputs @job.output end |
#save(path_or_dir, download_password = nil) ⇒ Object
Download the selected output to disk. Returns the path written to.
160 161 162 |
# File 'lib/api2convert/result.rb', line 160 def save(path_or_dir, download_password = nil) download.save(path_or_dir, download_password) end |
#to_s ⇒ Object
180 181 182 |
# File 'lib/api2convert/result.rb', line 180 def to_s inspect end |
#url ⇒ Object
The download URL of the selected output (self-contained, no auth).
155 156 157 |
# File 'lib/api2convert/result.rb', line 155 def url output.uri end |