Class: DFM
- Inherits:
-
Object
- Object
- DFM
- Defined in:
- lib/dfm.rb,
lib/dfm/version.rb
Constant Summary collapse
- VERSION =
"0.0.3"
Instance Attribute Summary collapse
-
#filters ⇒ Object
Returns the value of attribute filters.
Instance Method Summary collapse
- #hex(duplicates = true) ⇒ Object
-
#initialize(params = {}) ⇒ DFM
constructor
A new instance of DFM.
- #name(duplicates = true) ⇒ Object
- #print_duplicates(opt = "hex") ⇒ Object
- #print_singles(opt = "hex") ⇒ Object
- #recurse(path) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ DFM
8 9 10 11 12 13 14 15 |
# File 'lib/dfm.rb', line 8 def initialize( params = {} ) @files_by_hexdigest = {} @files_by_name = {} @filters = Array( params.fetch( :filters, nil ) ) @path = ( ( params.fetch( :path, '.' ) ) || '.' ) + File::SEPARATOR @hashFunc = Digest::MD5.new recurse_path( @path ) end |
Instance Attribute Details
#filters ⇒ Object
Returns the value of attribute filters.
6 7 8 |
# File 'lib/dfm.rb', line 6 def filters @filters end |
Instance Method Details
#hex(duplicates = true) ⇒ Object
25 26 27 |
# File 'lib/dfm.rb', line 25 def hex( duplicates = true ) select_duplicates( { :hash => @files_by_hexdigest, :duplicates => duplicates } ) end |
#name(duplicates = true) ⇒ Object
29 30 31 |
# File 'lib/dfm.rb', line 29 def name( duplicates = true ) select_duplicates( { :hash => @files_by_name, :duplicates => duplicates } ) end |
#print_duplicates(opt = "hex") ⇒ Object
21 22 23 |
# File 'lib/dfm.rb', line 21 def print_duplicates( opt = "hex" ) print_match( { :type => opt } ) end |
#print_singles(opt = "hex") ⇒ Object
17 18 19 |
# File 'lib/dfm.rb', line 17 def print_singles( opt = "hex" ) print_match( { :type => opt, :duplicates => false } ) end |
#recurse(path) ⇒ Object
33 34 35 36 37 |
# File 'lib/dfm.rb', line 33 def recurse( path ) @files_by_hexdigest = {} @files_by_name = {} recurse_path( path ) end |