Class: StreamdeckProf::LazyFile

Inherits:
Object
  • Object
show all
Defined in:
lib/streamdeck_prof/lazy_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_path) ⇒ LazyFile

Returns a new instance of LazyFile.



9
10
11
# File 'lib/streamdeck_prof/lazy_file.rb', line 9

def initialize(source_path)
  @source_path = source_path
end

Instance Attribute Details

#source_pathObject

Returns the value of attribute source_path.



7
8
9
# File 'lib/streamdeck_prof/lazy_file.rb', line 7

def source_path
  @source_path
end

Instance Method Details

#save(path) ⇒ Object



13
14
15
16
17
18
# File 'lib/streamdeck_prof/lazy_file.rb', line 13

def save(path)
  file_dir = File.dirname(path)
  FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)

  FileUtils.copy(source_path, path) unless File.realdirpath(path) == File.realdirpath(source_path)
end