class Codeowners::Checker::Group::Line

It sorts lines from CODEOWNERS file to different line types and holds shared methods for all lines.

Attributes

parent[RW]

Public Class Methods

build(line) click to toggle source
# File lib/codeowners/checker/group/line.rb, line 12
def self.build(line)
  subclasses.each do |klass|
    return klass.new(line) if klass.match?(line)
  end
  UnrecognizedLine.new(line)
end
new(line) click to toggle source
# File lib/codeowners/checker/group/line.rb, line 23
def initialize(line)
  @line = line
end
subclasses() click to toggle source
# File lib/codeowners/checker/group/line.rb, line 19
def self.subclasses
  [Empty, GroupBeginComment, GroupEndComment, Comment, Pattern]
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/codeowners/checker/group/line.rb, line 58
def <=>(other)
  to_s <=> other.to_s
end
==(other) click to toggle source
# File lib/codeowners/checker/group/line.rb, line 52
def ==(other)
  return false unless other.is_a?(self.class)

  other.to_s == to_s
end
pattern?() click to toggle source
# File lib/codeowners/checker/group/line.rb, line 39
def pattern?
  is_a?(Pattern)
end
remove!() click to toggle source
# File lib/codeowners/checker/group/line.rb, line 47
def remove!
  parent&.remove(self)
  self.parent = nil
end
to_content() click to toggle source
# File lib/codeowners/checker/group/line.rb, line 31
def to_content
  to_s
end
to_file() click to toggle source
# File lib/codeowners/checker/group/line.rb, line 35
def to_file
  to_s
end
to_s() click to toggle source
# File lib/codeowners/checker/group/line.rb, line 27
def to_s
  @line
end
to_tree(indentation) click to toggle source
# File lib/codeowners/checker/group/line.rb, line 43
def to_tree(indentation)
  indentation + to_s
end