Class: CurationConcerns::DerivativePath
- Inherits:
-
Object
- Object
- CurationConcerns::DerivativePath
- Defined in:
- app/services/curation_concerns/derivative_path.rb
Instance Attribute Summary collapse
-
#destination_name ⇒ Object
readonly
Returns the value of attribute destination_name.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
-
.derivative_path_for_reference(object, destination_name) ⇒ Object
Path on file system where derivative file is stored.
-
.derivatives_for_reference(object) ⇒ Array<String>
Array of paths to derivatives for this object.
Instance Method Summary collapse
- #all_paths ⇒ Object
- #derivative_path ⇒ Object
-
#initialize(object, destination_name = nil) ⇒ DerivativePath
constructor
A new instance of DerivativePath.
Constructor Details
#initialize(object, destination_name = nil) ⇒ DerivativePath
Returns a new instance of DerivativePath.
22 23 24 25 |
# File 'app/services/curation_concerns/derivative_path.rb', line 22 def initialize(object, destination_name = nil) @id = object.is_a?(String) ? object : object.id @destination_name = destination_name.gsub(/^original_file_/, '') if destination_name end |
Instance Attribute Details
#destination_name ⇒ Object (readonly)
Returns the value of attribute destination_name.
3 4 5 |
# File 'app/services/curation_concerns/derivative_path.rb', line 3 def destination_name @destination_name end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'app/services/curation_concerns/derivative_path.rb', line 3 def id @id end |
Class Method Details
.derivative_path_for_reference(object, destination_name) ⇒ Object
Path on file system where derivative file is stored
9 10 11 |
# File 'app/services/curation_concerns/derivative_path.rb', line 9 def derivative_path_for_reference(object, destination_name) new(object, destination_name).derivative_path end |
.derivatives_for_reference(object) ⇒ Array<String>
Returns Array of paths to derivatives for this object.
15 16 17 |
# File 'app/services/curation_concerns/derivative_path.rb', line 15 def derivatives_for_reference(object) new(object).all_paths end |
Instance Method Details
#all_paths ⇒ Object
31 32 33 34 35 |
# File 'app/services/curation_concerns/derivative_path.rb', line 31 def all_paths Dir.glob(root_path.join("*")).select do |path| path.start_with?(path_prefix.to_s) end end |
#derivative_path ⇒ Object
27 28 29 |
# File 'app/services/curation_concerns/derivative_path.rb', line 27 def derivative_path "#{path_prefix}-#{file_name}" end |