Class: Slices::Asset::Rename::Base
- Inherits:
-
Object
- Object
- Slices::Asset::Rename::Base
- Defined in:
- lib/slices/asset/rename.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#new_file_name ⇒ Object
Returns the value of attribute new_file_name.
Instance Method Summary collapse
-
#initialize(file, new_file_name) ⇒ Base
constructor
A new instance of Base.
- #rename(style) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(file, new_file_name) ⇒ Base
Returns a new instance of Base.
19 20 21 22 |
# File 'lib/slices/asset/rename.rb', line 19 def initialize(file, new_file_name) self.file = file self.new_file_name = new_file_name end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
17 18 19 |
# File 'lib/slices/asset/rename.rb', line 17 def file @file end |
#new_file_name ⇒ Object
Returns the value of attribute new_file_name.
17 18 19 |
# File 'lib/slices/asset/rename.rb', line 17 def new_file_name @new_file_name end |
Instance Method Details
#rename(style) ⇒ Object
31 32 33 34 |
# File 'lib/slices/asset/rename.rb', line 31 def rename(style) @old_path = file.path(style) @new_path = File.join(File.dirname(@old_path), @new_file_name) end |
#run ⇒ Object
24 25 26 27 28 29 |
# File 'lib/slices/asset/rename.rb', line 24 def run (file.styles.keys + [:original]).each do |style| next unless file.exists?(style) rename(style) end end |