class RubySearch::Search
Public Instance Methods
grep(regex)
click to toggle source
# File lib/ruby_search/search.rb, line 5 def grep(regex) $LOADED_FEATURES .select {|f| f =~ /\.rb\z/ } .lazy .select {|f| File.exist?(f) } .map {|f| [f, File.read(f)] } .reject {|x| x[1].to_s.empty? } .map do |file, stream| matches = stream .each_line .map { |line| regex.match(line) } .reject(&:nil?) .each.with_index(1) .to_a [file, matches] end end