Class: Marcdouane::Rules::NoConsecutiveBlankLines

Inherits:
Rule
  • Object
show all
Defined in:
lib/marcdouane/rules/no_consecutive_blank_lines.rb

Overview

Ensure there are no consecutive blank lines

Constant Summary collapse

ERROR_MESSAGE =
"Consecutive blank lines"

Instance Attribute Summary

Attributes inherited from Rule

#file, #markdown, #options

Instance Method Summary collapse

Methods inherited from Rule

#error!, #identifier, #initialize, #line_number_from_byte_range

Constructor Details

This class inherits a constructor from Marcdouane::Rules::Rule

Instance Method Details

#check!Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/marcdouane/rules/no_consecutive_blank_lines.rb', line 9

def check!
  @markdown
    .source
    .lines
    .each_cons(2)
    .each_with_index do |pair, index|
    if pair.map(&:strip).all?(&:empty?)
      error!(index + 2)
    end
  end
end