Class: Qdumpfs::BackupDir
- Inherits:
-
Object
- Object
- Qdumpfs::BackupDir
- Defined in:
- lib/qdumpfs/option.rb
Overview
日毎のバックアップフォルダに対応
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#keep ⇒ Object
Returns the value of attribute keep.
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
- .dump(dirs) ⇒ Object
- .find(backup_dirs, from_date, to_date) ⇒ Object
- .scan_backup_dirs(target_dir) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ BackupDir
constructor
A new instance of BackupDir.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ BackupDir
Returns a new instance of BackupDir.
30 31 32 |
# File 'lib/qdumpfs/option.rb', line 30 def initialize @keep = false end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
33 34 35 |
# File 'lib/qdumpfs/option.rb', line 33 def date @date end |
#keep ⇒ Object
Returns the value of attribute keep.
33 34 35 |
# File 'lib/qdumpfs/option.rb', line 33 def keep @keep end |
#path ⇒ Object
Returns the value of attribute path.
33 34 35 |
# File 'lib/qdumpfs/option.rb', line 33 def path @path end |
Class Method Details
.dump(dirs) ⇒ Object
24 25 26 27 28 |
# File 'lib/qdumpfs/option.rb', line 24 def self.dump(dirs) dirs.each do |dir| puts dir end end |
.find(backup_dirs, from_date, to_date) ⇒ Object
20 21 22 |
# File 'lib/qdumpfs/option.rb', line 20 def self.find(backup_dirs, from_date, to_date) backup_dirs.select{|backup_dir| backup_dir.date >= from_date && backup_dir.date <= to_date} end |
.scan_backup_dirs(target_dir) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/qdumpfs/option.rb', line 5 def self.scan_backup_dirs(target_dir) backup_dirs = [] Dir.glob("#{target_dir}/[0-9][0-9][0-9][0-9]/[0-1][0-9]/[0-3][0-9]").sort.each do |path| if File.directory?(path) && path =~ /(\d\d\d\d)\/(\d\d)\/(\d\d)/ # puts "Backup dir: #{path}" backup_dir = BackupDir.new backup_dir.path = path backup_dir.date = Date.new($1.to_i, $2.to_i, $3.to_i) backup_dirs << backup_dir end end backup_dirs.sort_by!{|backup_dir| backup_dir.date} backup_dirs end |
Instance Method Details
#to_s ⇒ Object
35 36 37 |
# File 'lib/qdumpfs/option.rb', line 35 def to_s "path=#{@path} date=#{@date} keep=#{@keep}" end |