Class: Rails::SourceAnnotationExtractor::ParserExtractor::Parser

Inherits:
Ripper
  • Object
show all
Defined in:
railties/lib/rails/source_annotation_extractor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, pattern:) ⇒ Parser

Returns a new instance of Parser.



22
23
24
25
26
# File 'railties/lib/rails/source_annotation_extractor.rb', line 22

def initialize(source, pattern:)
  super(source)
  @pattern = pattern
  @comments = []
end

Instance Attribute Details

#commentsObject (readonly)

Returns the value of attribute comments



20
21
22
# File 'railties/lib/rails/source_annotation_extractor.rb', line 20

def comments
  @comments
end

#patternObject (readonly)

Returns the value of attribute pattern



20
21
22
# File 'railties/lib/rails/source_annotation_extractor.rb', line 20

def pattern
  @pattern
end

Instance Method Details

#on_comment(value) ⇒ Object



28
29
30
# File 'railties/lib/rails/source_annotation_extractor.rb', line 28

def on_comment(value)
  @comments << Annotation.new(lineno, $1, $2) if value =~ pattern
end