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
42 43 44 |
# File 'railties/lib/rails/source_annotation_extractor.rb', line 42 def pattern @pattern end |
Instance Method Details
#annotations(file) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# 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 |