Class: Rails::SourceAnnotationExtractor::PatternExtractor
- Defined in:
- railties/lib/rails/source_annotation_extractor.rb
Overview
Wraps a regular expression that will iterate through a file’s lines and test each one for the given pattern.
Instance Attribute Summary collapse
-
#pattern ⇒ Object
Returns the value of attribute pattern.
Instance Method Summary collapse
Methods inherited from Struct
Instance Attribute Details
#pattern ⇒ Object
Returns the value of attribute pattern
31 32 33 |
# File 'railties/lib/rails/source_annotation_extractor.rb', line 31 def pattern @pattern end |
Instance Method Details
#annotations(file) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'railties/lib/rails/source_annotation_extractor.rb', line 32 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 |