Class: Slices::Asset::Rename::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/slices/asset/rename.rb

Direct Known Subclasses

Filesystem, Fog

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#fileObject

Returns the value of attribute file.



17
18
19
# File 'lib/slices/asset/rename.rb', line 17

def file
  @file
end

#new_file_nameObject

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

#runObject



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