Class: DTK::DSL::FileType::MatchingFiles

Inherits:
Object
  • Object
show all
Defined in:
lib/dsl/file_type/matching_files.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#file_pathsObject (readonly)

Returns the value of attribute file_paths.



22
23
24
# File 'lib/dsl/file_type/matching_files.rb', line 22

def file_paths
  @file_paths
end

#file_type_instanceObject (readonly)

Returns the value of attribute file_type_instance.



22
23
24
# File 'lib/dsl/file_type/matching_files.rb', line 22

def file_type_instance
  @file_type_instance
end

Class Method Details

.matching_files_array(file_type_classes, file_paths) ⇒ Object

Returns array of MatchingFiles



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/dsl/file_type/matching_files.rb', line 35

def self.matching_files_array(file_type_classes, file_paths)
  ndx_ret = {}
  file_type_classes = [file_type_classes] unless file_type_classes.kind_of?(Array)
  file_type_classes.each do |file_type_class|
    file_paths.each do |file_path|
      if file_type_instance = file_type_class.file_type_instance_if_match?(file_path)
        file_type_instance_index = file_type_instance.index
        if matching_index = ndx_ret.keys.find { |index| index == file_type_instance_index }
          ndx_ret[matching_index].add_file_path!(file_path)
        else
          ndx_ret[file_type_instance_index] = new(file_type_instance).add_file_path!(file_path)
        end
      end
    end
  end
  ndx_ret.values
end

Instance Method Details

#add_file_path!(file_path) ⇒ Object



29
30
31
32
# File 'lib/dsl/file_type/matching_files.rb', line 29

def add_file_path!(file_path)
  @file_paths << file_path
  self
end