Class: TreeRb::ContentFile
- Inherits:
-
Object
- Object
- TreeRb::ContentFile
- Defined in:
- lib/tree_rb/visitors_file_system/build_dir_tree_visitor.rb
Overview
contains information related to file (LeafNode)
Instance Method Summary collapse
-
#initialize(pathname, options) ⇒ ContentFile
constructor
A new instance of ContentFile.
- #to_str ⇒ Object
Constructor Details
#initialize(pathname, options) ⇒ ContentFile
Returns a new instance of ContentFile.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/tree_rb/visitors_file_system/build_dir_tree_visitor.rb', line 25 def initialize(pathname, ) stat = File.lstat(pathname) # stat.symlink? if [:show_full_path] file_name = pathname else file_name = File.basename(pathname) end if [:show_md5sum] @str = "#{MD5.file(pathname).hexdigest} #{file_name}" return end if [:show_sha1sum] @str = "#{SHA1.file(pathname).hexdigest} #{file_name}" return end if [:show_size] str = "#{file_name} #{stat.size}" elsif [:show_size_human] str = "#{file_name} #{stat.size.to_human}" else str = "#{file_name}" end if [:show_md5] str << " md5: #{MD5.file(pathname).hexdigest}" end if [:show_sha1] str << " sha1: #{SHA1.file(pathname).hexdigest}" end @str = str end |
Instance Method Details
#to_str ⇒ Object
63 64 65 |
# File 'lib/tree_rb/visitors_file_system/build_dir_tree_visitor.rb', line 63 def to_str @str end |