Class: DirCat::Entry
- Inherits:
-
Object
- Object
- DirCat::Entry
- Defined in:
- lib/dircat/cat_on_yaml/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
19 20 21 |
# File 'lib/dircat/cat_on_yaml/entry.rb', line 19 def md5 @md5 end |
#mtime ⇒ Object
Returns the value of attribute mtime.
23 24 25 |
# File 'lib/dircat/cat_on_yaml/entry.rb', line 23 def mtime @mtime end |
#name ⇒ Object
Returns the value of attribute name.
20 21 22 |
# File 'lib/dircat/cat_on_yaml/entry.rb', line 20 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
21 22 23 |
# File 'lib/dircat/cat_on_yaml/entry.rb', line 21 def path @path end |
#size ⇒ Object
Returns the value of attribute size.
22 23 24 |
# File 'lib/dircat/cat_on_yaml/entry.rb', line 22 def size @size end |
Class Method Details
.from_filename(filename) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dircat/cat_on_yaml/entry.rb', line 25 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
37 38 39 40 41 42 43 44 45 |
# File 'lib/dircat/cat_on_yaml/entry.rb', line 37 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
57 58 59 |
# File 'lib/dircat/cat_on_yaml/entry.rb', line 57 def to_s @md5 + " " + @name + "\t " + @path + "\n" end |
#to_ser ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/dircat/cat_on_yaml/entry.rb', line 47 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 |