Class: Debtective::Comments::BuildComment
- Inherits:
-
Object
- Object
- Debtective::Comments::BuildComment
- Defined in:
- lib/debtective/comments/build_comment.rb
Overview
Build proper comment type given the code line
Constant Summary collapse
- TYPES =
Order matters, for example the Comment::Note regex matches (almost) all previous regexes so it needs to be tested last
{ /#\sTODO:/ => Comment::Todo, /#\sFIXME:/ => Comment::Fixme, /\s# rubocop:disable (.*)/ => Comment::Offense, /#\s@/ => Comment::Yard, /^# (frozen_string_literal|coding|encoding|warn_indent|sharable_constant_value):/ => Comment::Magic, /^#!/ => Comment::Shebang, /(^|\s)#\s/ => Comment::Note }.freeze
Instance Method Summary collapse
- #call ⇒ Debtective::Comments::Base
-
#initialize(line:, pathname:, index:) ⇒ BuildComment
constructor
A new instance of BuildComment.
Constructor Details
#initialize(line:, pathname:, index:) ⇒ BuildComment
Returns a new instance of BuildComment.
30 31 32 33 34 |
# File 'lib/debtective/comments/build_comment.rb', line 30 def initialize(line:, pathname:, index:) @line = line @pathname = pathname @index = index end |
Instance Method Details
#call ⇒ Debtective::Comments::Base
37 38 39 |
# File 'lib/debtective/comments/build_comment.rb', line 37 def call klass&.new(pathname: @pathname, index: @index) end |