Class: FileEntry
- Inherits:
-
Object
- Object
- FileEntry
- 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
-
#checksum ⇒ Object
Returns the value of attribute checksum.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
-
#initialize(path, name) ⇒ FileEntry
constructor
A new instance of FileEntry.
-
#last_modified ⇒ Object
Get the last_modified date.
-
#last_modified=(date) ⇒ Object
Set the last_modified date.
-
#to_s ⇒ Object
Overrides to_s to get a human readable output.
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
#checksum ⇒ Object
Returns the value of attribute checksum.
4 5 6 |
# File 'lib/filentory/fileentry.rb', line 4 def checksum @checksum end |
#metadata ⇒ Object
Returns the value of attribute metadata.
4 5 6 |
# File 'lib/filentory/fileentry.rb', line 4 def @metadata end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/filentory/fileentry.rb', line 4 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/filentory/fileentry.rb', line 4 def path @path end |
#size ⇒ Object
Returns the value of attribute size.
4 5 6 |
# File 'lib/filentory/fileentry.rb', line 4 def size @size end |
Instance Method Details
#last_modified ⇒ Object
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_s ⇒ Object
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 |