Class: Yamlint::Parser::CommentExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/yamlint/parser/comment_extractor.rb

Constant Summary collapse

COMMENT_PATTERN =
/#(.*)$/

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ CommentExtractor

Returns a new instance of CommentExtractor.



39
40
41
# File 'lib/yamlint/parser/comment_extractor.rb', line 39

def initialize(content)
  @content = content
end

Instance Method Details

#extractObject



43
44
45
46
47
48
49
50
# File 'lib/yamlint/parser/comment_extractor.rb', line 43

def extract
  comments = []
  @content.lines.each_with_index do |line, index|
    line_number = index + 1
    extract_comments_from_line(line, line_number, comments)
  end
  comments
end