Class: RailsOpenapiGen::Parsers::Jbuilder::PropertyCommentParser
- Inherits:
-
Object
- Object
- RailsOpenapiGen::Parsers::Jbuilder::PropertyCommentParser
- Defined in:
- lib/rails-openapi-gen/parsers/jbuilder/property_comment_parser.rb
Instance Method Summary collapse
-
#find_property_comment_for_line(line_number) ⇒ Hash?
Finds property comment for a specific line.
-
#initialize(comments) ⇒ PropertyCommentParser
constructor
Initializes property comment parser.
Constructor Details
#initialize(comments) ⇒ PropertyCommentParser
Initializes property comment parser
9 10 11 12 |
# File 'lib/rails-openapi-gen/parsers/jbuilder/property_comment_parser.rb', line 9 def initialize(comments) @comments = comments @comment_parser = RailsOpenapiGen::Parsers::CommentParser.new end |
Instance Method Details
#find_property_comment_for_line(line_number) ⇒ Hash?
Finds property comment for a specific line
17 18 19 20 21 22 23 24 |
# File 'lib/rails-openapi-gen/parsers/jbuilder/property_comment_parser.rb', line 17 def find_property_comment_for_line(line_number) @comments.reverse.find do |comment| comment_line = comment.location.line comment_line == line_number - 1 || comment_line == line_number end&.then do |comment| @comment_parser.parse(comment.text) end end |