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.



30
31
32
33
34
35
36
# File 'lib/backup/package.rb', line 30

def initialize(model)
  @trigger = model.trigger
  @extension = 'tar'
  @chunk_suffixes = Array.new
  @no_cycle = false
  @version = VERSION
end

Instance Attribute Details

#chunk_suffixesObject

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



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

def chunk_suffixes
  @chunk_suffixes
end

#extensionObject

Extension for the final archive file(s)



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

def extension
  @extension
end

#no_cycleObject

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



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

def no_cycle
  @no_cycle
end

#timeObject

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



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

def time
  @time
end

#triggerObject (readonly)

The trigger which initiated the backup process



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

def trigger
  @trigger
end

#versionObject (readonly)

The version of Backup used to create the package



28
29
30
# File 'lib/backup/package.rb', line 28

def version
  @version
end

Instance Method Details

#basenameObject



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

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

#filenamesObject



38
39
40
41
42
43
44
# File 'lib/backup/package.rb', line 38

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

#time_as_objectObject



50
51
52
# File 'lib/backup/package.rb', line 50

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