Class: DirCat::Entry
- Inherits:
-
Object
- Object
- DirCat::Entry
- Defined in:
- lib/tree_rb/output_plugins/dircat/entry.rb
Overview
Entry
Instance Attribute Summary collapse
-
#md5 ⇒ Object
TODO: must be attr_reader.
-
#mtime ⇒ Object
Returns the value of attribute mtime.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#size ⇒ Object
Returns the value of attribute size.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#md5 ⇒ Object
TODO: must be attr_reader
21 22 23 |
# File 'lib/tree_rb/output_plugins/dircat/entry.rb', line 21 def md5 @md5 end |
#mtime ⇒ Object
Returns the value of attribute mtime.
25 26 27 |
# File 'lib/tree_rb/output_plugins/dircat/entry.rb', line 25 def mtime @mtime end |
#name ⇒ Object
Returns the value of attribute name.
22 23 24 |
# File 'lib/tree_rb/output_plugins/dircat/entry.rb', line 22 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
23 24 25 |
# File 'lib/tree_rb/output_plugins/dircat/entry.rb', line 23 def path @path end |
#size ⇒ Object
Returns the value of attribute size.
24 25 26 |
# File 'lib/tree_rb/output_plugins/dircat/entry.rb', line 24 def size @size end |
Class Method Details
.from_filename(filename) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/tree_rb/output_plugins/dircat/entry.rb', line 27 def self.from_filename(filename) entry = new entry.name = File.basename(filename) entry.path = File.dirname(filename) stat = File.lstat(filename) entry.size = stat.size entry.mtime = stat.mtime # self.md5 = Digest::MD5.hexdigest(File.read( f )) entry.md5 = MD5.file(filename).hexdigest unless stat.symlink? entry end |
.from_ser(entry_ser) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/tree_rb/output_plugins/dircat/entry.rb', line 39 def self.from_ser(entry_ser) entry = new entry.md5 = entry_ser.md5 entry.name = entry_ser.name entry.path = entry_ser.path entry.size = entry_ser.size entry.mtime = entry_ser.mtime entry end |
Instance Method Details
#to_s ⇒ Object
59 60 61 |
# File 'lib/tree_rb/output_plugins/dircat/entry.rb', line 59 def to_s @md5 + " " + @name + "\t " + @path + "\n" end |
#to_ser ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/tree_rb/output_plugins/dircat/entry.rb', line 49 def to_ser entry_ser = EntrySer.new entry_ser.md5 = @md5 entry_ser.name = @name entry_ser.path = @path entry_ser.size = @size entry_ser.mtime = @mtime entry_ser end |