Class: Synqa::FileContent

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

Overview

An object representing the content of a file within a ContentTree. The file may be marked for copying (if it’s in a source ContentTree) or for deletion (if it’s in a destination ContentTree)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, hash, parentPathElements) ⇒ FileContent

Returns a new instance of FileContent.



296
297
298
299
300
301
302
# File 'lib/synqa.rb', line 296

def initialize(name, hash, parentPathElements)
  @name = name
  @hash = hash
  @parentPathElements = parentPathElements
  @copyDestination = nil
  @toBeDeleted = false
end

Instance Attribute Details

#copyDestinationObject (readonly)

The destination to which the file should be copied



291
292
293
# File 'lib/synqa.rb', line 291

def copyDestination
  @copyDestination
end

#hashObject (readonly)

The hash value of the file’s contents



285
286
287
# File 'lib/synqa.rb', line 285

def hash
  @hash
end

#nameObject (readonly)

The name of the file



282
283
284
# File 'lib/synqa.rb', line 282

def name
  @name
end

#parentPathElementsObject (readonly)

The components of the relative path where the file is found



288
289
290
# File 'lib/synqa.rb', line 288

def parentPathElements
  @parentPathElements
end

#toBeDeletedObject (readonly)

Should this file be deleted



294
295
296
# File 'lib/synqa.rb', line 294

def toBeDeleted
  @toBeDeleted
end

Instance Method Details

#fullPathObject

The full (relative) name of this file in the content tree



319
320
321
# File 'lib/synqa.rb', line 319

def fullPath
  return (parentPathElements + [name]).join("/")
end

#markToCopy(destinationDirectory) ⇒ Object

Mark this file to be copied to a destination directory (from a destination content tree)



305
306
307
# File 'lib/synqa.rb', line 305

def markToCopy(destinationDirectory)
  @copyDestination = destinationDirectory
end

#markToDeleteObject

Mark this file to be deleted



310
311
312
# File 'lib/synqa.rb', line 310

def markToDelete
  @toBeDeleted = true
end

#to_sObject



314
315
316
# File 'lib/synqa.rb', line 314

def to_s
  return "#{name} (#{hash})"
end