class RegexFileProcesser
Public Class Methods
new(regex, genLineFunc)
click to toggle source
# File lib/file_processer.rb, line 34 def initialize(regex, genLineFunc) @regex = regex @genLineFunc = genLineFunc end
Public Instance Methods
process(filePath)
click to toggle source
# File lib/file_processer.rb, line 39 def process(filePath) buffer = "" IO.foreach(filePath) { |line| current_number_regex = line =~ @regex if current_number_regex regexCatchedValue = $~ buffer += line.gsub(@regex, @genLineFunc.call(regexCatchedValue)) else buffer += line end } YDFileUtils.writeFile(filePath, buffer) end