Class: Shrine::Plugins::Transloadit::TransloaditFile
- Inherits:
-
Object
- Object
- Shrine::Plugins::Transloadit::TransloaditFile
- Defined in:
- lib/shrine/plugins/transloadit.rb
Instance Attribute Summary collapse
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
-
#transloadit ⇒ Object
readonly
Returns the value of attribute transloadit.
Instance Method Summary collapse
-
#add_step(*args) ⇒ Object
Adds a step to the pipeline, automatically setting :use to the previous step, so that later multiple pipelines can be seamlessly joined into a single assembly.
-
#exported? ⇒ Boolean
Returns true if this TransloaditFile includes an export step.
-
#imported? ⇒ Boolean
Returns true if this TransloaditFile includes an import step.
-
#initialize(transloadit:, steps: [], multiple: nil) ⇒ TransloaditFile
constructor
A new instance of TransloaditFile.
-
#multiple(format = nil) ⇒ Object
Specify the result format.
-
#name ⇒ Object
The key that Transloadit will use in its processing results for the corresponding processed file.
Constructor Details
#initialize(transloadit:, steps: [], multiple: nil) ⇒ TransloaditFile
Returns a new instance of TransloaditFile.
343 344 345 346 347 |
# File 'lib/shrine/plugins/transloadit.rb', line 343 def initialize(transloadit:, steps: [], multiple: nil) @transloadit = transloadit @steps = steps @multiple = multiple end |
Instance Attribute Details
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
341 342 343 |
# File 'lib/shrine/plugins/transloadit.rb', line 341 def steps @steps end |
#transloadit ⇒ Object (readonly)
Returns the value of attribute transloadit.
341 342 343 |
# File 'lib/shrine/plugins/transloadit.rb', line 341 def transloadit @transloadit end |
Instance Method Details
#add_step(*args) ⇒ Object
Adds a step to the pipeline, automatically setting :use to the previous step, so that later multiple pipelines can be seamlessly joined into a single assembly.
It returns a new TransloaditFile with the step added.
354 355 356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/shrine/plugins/transloadit.rb', line 354 def add_step(*args) if args[0].is_a?(::Transloadit::Step) step = args[0] else step = transloadit.step(*args) end unless step.[:use] step.use steps.last if steps.any? end transloadit_file(steps: steps + [step]) end |
#exported? ⇒ Boolean
Returns true if this TransloaditFile includes an export step.
394 395 396 |
# File 'lib/shrine/plugins/transloadit.rb', line 394 def exported? @steps.any? && @steps.last.robot.end_with?("/store") end |
#imported? ⇒ Boolean
Returns true if this TransloaditFile includes an import step.
389 390 391 |
# File 'lib/shrine/plugins/transloadit.rb', line 389 def imported? @steps.any? && @steps.first.robot.end_with?("/import") end |
#multiple(format = nil) ⇒ Object
Specify the result format.
369 370 371 372 373 374 375 |
# File 'lib/shrine/plugins/transloadit.rb', line 369 def multiple(format = nil) if format transloadit_file(multiple: format) else @multiple end end |
#name ⇒ Object
The key that Transloadit will use in its processing results for the corresponding processed file. This equals to the name of the last step, unless the last step is an export step.
380 381 382 383 384 385 386 |
# File 'lib/shrine/plugins/transloadit.rb', line 380 def name if exported? @steps[-2].name else @steps.last.name end end |