Class: Codeowners::Checker::Group::Comment

Inherits:
Line
  • Object
show all
Defined in:
lib/codeowners/checker/group/comment.rb

Overview

Define and manage comment line.

Direct Known Subclasses

GroupBeginComment, GroupEndComment

Instance Attribute Summary

Attributes inherited from Line

#parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Line

#<=>, #==, build, #initialize, #pattern?, #remove!, subclasses, #to_content, #to_file, #to_s, #to_tree

Constructor Details

This class inherits a constructor from Codeowners::Checker::Group::Line

Class Method Details

.match?(line) ⇒ Boolean

Matches if the line is a comment.

Returns:

  • (Boolean)

    if the line start with ‘#`



12
13
14
# File 'lib/codeowners/checker/group/comment.rb', line 12

def self.match?(line)
  line.start_with?('#')
end

Instance Method Details

#levelInteger

Return the comment level if the comment works like a markdown headers.

Examples:

Comment.new('# First level').level # => 1
Comment.new('## Second').level # => 2

Returns:

  • (Integer)

    with the heading level.



23
24
25
# File 'lib/codeowners/checker/group/comment.rb', line 23

def level
  (@line[/^#+/] || '').size
end