Class: Organisir::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/organisir/rule.rb

Instance Method Summary collapse

Constructor Details

#initialize(dirs) ⇒ Rule

Returns a new instance of Rule.



5
6
7
8
9
10
11
# File 'lib/organisir/rule.rb', line 5

def initialize(dirs)
  @dirs = dirs
  @dir_map = {}
  @dirs.map do |dir|
    @dir_map[dir] = Util.gen_regex_for_dir_name(dir)
  end
end

Instance Method Details

#match(file) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/organisir/rule.rb', line 13

def match(file)
  resp = []
  @dir_map.keys.each do |k|
    resp << k if file.downcase.match(@dir_map[k])
  end

  resp
end