class FileCrawler::Finder::Command::Collect::Organizer
Public Instance Methods
decide_index(string, regexs=[])
click to toggle source
# File lib/file_crawler/finder/command/collect.rb, line 61 def decide_index(string, regexs=[]) if !regexs.empty? regexs.each {|regex| return $1.strip unless regex.pattern.match(string).nil? } end pattern = /[\p{Hiragana}|\p{Katakana}|\p{Han}|[a-zA-Z0-9]ー ]+/ result = string.strip.scan(pattern).first return result.strip unless result.nil? string.strip end
run(filepaths, regexs)
click to toggle source
# File lib/file_crawler/finder/command/collect.rb, line 48 def run(filepaths, regexs) hash = {} filepaths.each {|filepath| filename = File.basename(filepath) term = decide_index(filename, regexs) hash[term] ||= [] hash[term] << filepath } hash end