Class: RubyClone::Backup

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_clone/profile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, options = { }) ⇒ Backup

Returns a new instance of Backup.



95
96
97
98
99
100
# File 'lib/ruby_clone/profile.rb', line 95

def initialize(path, options = { })
  @default_suffix = '_rbcl'
  @options = { disable_suffix: false, limit: 5 }.merge(options)
  @path = path

end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



93
94
95
# File 'lib/ruby_clone/profile.rb', line 93

def path
  @path
end

Instance Method Details

#delete_filesObject



102
103
104
# File 'lib/ruby_clone/profile.rb', line 102

def delete_files
  BackupUtils.delete_files @path, @default_suffix, @options[:limit] if @options[:limit] != :unlimited
end

#to_commandObject



106
107
108
109
110
111
# File 'lib/ruby_clone/profile.rb', line 106

def to_command
  command = "-b "
  command << "#{create_suffix} " if not @options[:disable_suffix]
  command << "--backup-dir=#{path} "
  command.strip
end