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

Inherits:
Ripper
  • Object
show all
Defined in:
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.



38
39
40
41
42
# File 'lib/rails/source_annotation_extractor.rb', line 38

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

Instance Attribute Details

#commentsObject (readonly)

Returns the value of attribute comments.



36
37
38
# File 'lib/rails/source_annotation_extractor.rb', line 36

def comments
  @comments
end

#patternObject (readonly)

Returns the value of attribute pattern.



36
37
38
# File 'lib/rails/source_annotation_extractor.rb', line 36

def pattern
  @pattern
end

Instance Method Details

#on_comment(value) ⇒ Object



44
45
46
# File 'lib/rails/source_annotation_extractor.rb', line 44

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