Class: FileEntry

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

Overview

FileEntry is used as a simple container to store information about the file like metadata, size or checksum.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, name) ⇒ FileEntry

Returns a new instance of FileEntry.



6
7
8
9
# File 'lib/filentory/fileentry.rb', line 6

def initialize(path, name)
  @path = path
  @name = name
end

Instance Attribute Details

#checksumObject

Returns the value of attribute checksum.



4
5
6
# File 'lib/filentory/fileentry.rb', line 4

def checksum
  @checksum
end

#metadataObject

Returns the value of attribute metadata.



4
5
6
# File 'lib/filentory/fileentry.rb', line 4

def 
  @metadata
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/filentory/fileentry.rb', line 4

def name
  @name
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/filentory/fileentry.rb', line 4

def path
  @path
end

#sizeObject

Returns the value of attribute size.



4
5
6
# File 'lib/filentory/fileentry.rb', line 4

def size
  @size
end

Instance Method Details

#last_modifiedObject

Get the last_modified date



18
19
20
# File 'lib/filentory/fileentry.rb', line 18

def last_modified
  DateTime.iso8601(@last_modified)
end

#last_modified=(date) ⇒ Object

Set the last_modified date. It uses the date.strftime method to convert it in a ISO 8601 format to be radable in JSON.



13
14
15
# File 'lib/filentory/fileentry.rb', line 13

def last_modified=(date)
  @last_modified = date.strftime("%FT%T%:z")
end

#to_sObject

Overrides to_s to get a human readable output.



23
24
25
# File 'lib/filentory/fileentry.rb', line 23

def to_s
  @path + @name + " (" + @size.to_s + ") - " + @last_modified
end