Class: Backup::Syncer::Cloud::LocalFile

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(directory, line) ⇒ LocalFile

Creates a new LocalFile object using the given directory and line from the md5 hash checkup. This object figures out the path, relative_path and md5 hash for the file.



176
177
178
179
# File 'lib/backup/syncer/cloud.rb', line 176

def initialize(directory, line)
  @directory  = directory
  @path, @md5 = *line.chomp.match(/^MD5\(([^\)]+)\)= (\w+)$/).captures
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



170
171
172
# File 'lib/backup/syncer/cloud.rb', line 170

def directory
  @directory
end

#md5Object (readonly)

Returns the value of attribute md5.



170
171
172
# File 'lib/backup/syncer/cloud.rb', line 170

def md5
  @md5
end

#pathObject (readonly)

Returns the value of attribute path.



170
171
172
# File 'lib/backup/syncer/cloud.rb', line 170

def path
  @path
end

Instance Method Details

#relative_pathObject

Returns the relative path to the file.



183
184
185
186
# File 'lib/backup/syncer/cloud.rb', line 183

def relative_path
  @relative_path ||= path.gsub %r{^#{directory}},
    directory.split('/').last
end