Class: PXCBackup::Backup
- Inherits:
-
Object
- Object
- PXCBackup::Backup
- Defined in:
- lib/pxcbackup/backup.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #delete ⇒ Object
- #encrypted? ⇒ Boolean
- #full? ⇒ Boolean
- #incremental? ⇒ Boolean
-
#initialize(repo, path) ⇒ Backup
constructor
A new instance of Backup.
- #remote? ⇒ Boolean
- #stream ⇒ Object
- #stream_command ⇒ Object
- #time ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(repo, path) ⇒ Backup
Returns a new instance of Backup.
5 6 7 8 9 |
# File 'lib/pxcbackup/backup.rb', line 5 def initialize(repo, path) @repo = repo @path = path raise 'invalid backup name' unless match end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/pxcbackup/backup.rb', line 3 def path @path end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
3 4 5 |
# File 'lib/pxcbackup/backup.rb', line 3 def repo @repo end |
Class Method Details
.regexp ⇒ Object
11 12 13 |
# File 'lib/pxcbackup/backup.rb', line 11 def self.regexp /\/(\d+)_(full|incr)\.(xbstream|tar)(\.xbcrypt)?$/ end |
Instance Method Details
#<=>(other) ⇒ Object
19 20 21 22 23 |
# File 'lib/pxcbackup/backup.rb', line 19 def <=>(other) compare = time <=> other.time compare = remote? ? -1 : 1 if compare == 0 && remote? != other.remote? compare end |
#==(other) ⇒ Object
15 16 17 |
# File 'lib/pxcbackup/backup.rb', line 15 def ==(other) @path == other.path && @repo == other.repo end |
#delete ⇒ Object
59 60 61 |
# File 'lib/pxcbackup/backup.rb', line 59 def delete @repo.delete(self) end |
#encrypted? ⇒ Boolean
43 44 45 |
# File 'lib/pxcbackup/backup.rb', line 43 def encrypted? match[:encrypted] end |
#full? ⇒ Boolean
47 48 49 |
# File 'lib/pxcbackup/backup.rb', line 47 def full? type == :full end |
#incremental? ⇒ Boolean
51 52 53 |
# File 'lib/pxcbackup/backup.rb', line 51 def incremental? type == :incremental end |
#remote? ⇒ Boolean
55 56 57 |
# File 'lib/pxcbackup/backup.rb', line 55 def remote? @repo.is_a? RemoteRepo end |
#stream ⇒ Object
39 40 41 |
# File 'lib/pxcbackup/backup.rb', line 39 def stream match[:stream].to_sym end |
#stream_command ⇒ Object
63 64 65 |
# File 'lib/pxcbackup/backup.rb', line 63 def stream_command @repo.stream_command(self) end |
#time ⇒ Object
29 30 31 |
# File 'lib/pxcbackup/backup.rb', line 29 def time Time.at(match[:timestamp].to_i) end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/pxcbackup/backup.rb', line 25 def to_s time.to_s end |
#type ⇒ Object
33 34 35 36 37 |
# File 'lib/pxcbackup/backup.rb', line 33 def type type = match[:type] type = 'incremental' if type == 'incr' type.to_sym end |