Class: Entry
- Inherits:
-
Object
- Object
- Entry
- Defined in:
- lib/dircat/dircat.rb
Overview
Entry
Instance Attribute Summary collapse
-
#md5 ⇒ Object
readonly
Returns the value of attribute md5.
-
#mtime ⇒ Object
readonly
Returns the value of attribute mtime.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
Instance Attribute Details
#md5 ⇒ Object (readonly)
Returns the value of attribute md5.
26 27 28 |
# File 'lib/dircat/dircat.rb', line 26 def md5 @md5 end |
#mtime ⇒ Object (readonly)
Returns the value of attribute mtime.
30 31 32 |
# File 'lib/dircat/dircat.rb', line 30 def mtime @mtime end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
27 28 29 |
# File 'lib/dircat/dircat.rb', line 27 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
28 29 30 |
# File 'lib/dircat/dircat.rb', line 28 def path @path end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
29 30 31 |
# File 'lib/dircat/dircat.rb', line 29 def size @size end |
Instance Method Details
#from_filename(filename) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dircat/dircat.rb', line 32 def from_filename( filename ) # puts "Entry::initialize #f" if $VERBOSE_LEVEL > 0 cr = "\r" clear = "\e[K" print "#{cr}#{filename}#{clear}" end @name = File.basename(filename) @path = File.dirname(filename) stat = File.stat(filename) @size = stat.size @mtime = stat.mtime # self.md5 = Digest::MD5.hexdigest(File.read( f )) @md5 = MD5.file( filename ).hexdigest self end |
#from_ser(entry_ser) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/dircat/dircat.rb', line 49 def from_ser( entry_ser ) @md5 = entry_ser.md5 @name = entry_ser.name @path = entry_ser.path @size = entry_ser.size @mtime = entry_ser.mtime self end |
#to_s ⇒ Object
68 69 70 |
# File 'lib/dircat/dircat.rb', line 68 def to_s @md5 + " " + @name + "\t " + @path + "\n" end |
#to_ser ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/dircat/dircat.rb', line 58 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 |