Class: Backup::Package

Inherits:
Object
  • Object
show all
Defined in:
lib/backup/package.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ Package

Returns a new instance of Package.



27
28
29
30
31
32
33
# File 'lib/backup/package.rb', line 27

def initialize(model)
  @trigger = model.trigger
  @extension = "tar"
  @chunk_suffixes = []
  @no_cycle = false
  @version = VERSION
end

Instance Attribute Details

#chunk_suffixesObject

Set by the Splitter if the final archive was “chunked”



17
18
19
# File 'lib/backup/package.rb', line 17

def chunk_suffixes
  @chunk_suffixes
end

#extensionObject

Extension for the final archive file(s)



13
14
15
# File 'lib/backup/package.rb', line 13

def extension
  @extension
end

#no_cycleObject

If true, the Cycler will not attempt to remove the package when Cycling.



21
22
23
# File 'lib/backup/package.rb', line 21

def no_cycle
  @no_cycle
end

#timeObject

The time when the backup initiated (in format: 2011.02.20.03.29.59)



5
6
7
# File 'lib/backup/package.rb', line 5

def time
  @time
end

#triggerObject (readonly)

The trigger which initiated the backup process



9
10
11
# File 'lib/backup/package.rb', line 9

def trigger
  @trigger
end

#versionObject (readonly)

The version of Backup used to create the package



25
26
27
# File 'lib/backup/package.rb', line 25

def version
  @version
end

Instance Method Details

#basenameObject



43
44
45
# File 'lib/backup/package.rb', line 43

def basename
  "#{trigger}.#{extension}"
end

#filenamesObject



35
36
37
38
39
40
41
# File 'lib/backup/package.rb', line 35

def filenames
  if chunk_suffixes.empty?
    [basename]
  else
    chunk_suffixes.map { |suffix| "#{basename}-#{suffix}" }
  end
end

#time_as_objectObject



47
48
49
# File 'lib/backup/package.rb', line 47

def time_as_object
  Time.strptime(time, "%Y.%m.%d.%H.%M.%S")
end