Class: Outback::Archive

Inherits:
Object show all
Defined in:
lib/outback/archive.rb

Direct Known Subclasses

SourceArchive, TargetArchive

Constant Summary collapse

NAME_PATTERN =
/\A([A-Za-z0-9.\-]+)_(\d{14})_(\w+)/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Archive

Returns a new instance of Archive.



7
8
9
10
11
12
13
# File 'lib/outback/archive.rb', line 7

def initialize(filename)
  @filename = Pathname.new(filename)
  unless match_data = @filename.basename.to_s.match(NAME_PATTERN)
    raise ArgumentError, 'invalid name'
  end
  @backup_name, @timestamp, @source_name = match_data.captures[0..2]
end

Instance Attribute Details

#backup_nameObject (readonly)

Returns the value of attribute backup_name.



5
6
7
# File 'lib/outback/archive.rb', line 5

def backup_name
  @backup_name
end

#filenameObject (readonly)

Returns the value of attribute filename.



5
6
7
# File 'lib/outback/archive.rb', line 5

def filename
  @filename
end

#sizeObject (readonly)

Returns the value of attribute size.



5
6
7
# File 'lib/outback/archive.rb', line 5

def size
  @size
end

#source_nameObject (readonly)

Returns the value of attribute source_name.



5
6
7
# File 'lib/outback/archive.rb', line 5

def source_name
  @source_name
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



5
6
7
# File 'lib/outback/archive.rb', line 5

def timestamp
  @timestamp
end

Instance Method Details

#to_sObject



15
16
17
# File 'lib/outback/archive.rb', line 15

def to_s
  "#{filename}"
end