Skip to Content Skip to Search

class Rails::SourceAnnotationExtractor::PatternExtractor

Wraps a regular expression that will iterate through a file’s lines and test each one for the given pattern.

Inherits From

Public instance methods

Source code GitHub
# File railties/lib/rails/source_annotation_extractor.rb, line 43
def annotations(file)
  lineno = 0

  File.readlines(file, encoding: Encoding::BINARY).inject([]) do |list, line|
    lineno += 1
    next list unless line =~ pattern
    list << Annotation.new(lineno, $1, $2)
  end
end

Definition files