class FrontMatterParser::SyntaxParser::MultiLineComment

Parser for syntaxes which use end and finish comment delimiters

Attributes

regexp[R]

@!attribute [r] regexp A regexp that returns two groups: front_matter and content

Public Class Methods

delimiters() click to toggle source

@see Factorizable :nocov:

# File lib/front_matter_parser/syntax_parser/multi_line_comment.rb, line 24
def self.delimiters
  raise NotImplementedError
end
new() click to toggle source
# File lib/front_matter_parser/syntax_parser/multi_line_comment.rb, line 13
def initialize
  @regexp = build_regexp(*self.class.delimiters)
end

Public Instance Methods

call(string) click to toggle source

@see SyntaxParser

# File lib/front_matter_parser/syntax_parser/multi_line_comment.rb, line 18
def call(string)
  string.match(regexp)
end

Private Instance Methods

build_regexp(start_delimiter, end_delimiter) click to toggle source

rubocop:disable Metrics/MethodLength

# File lib/front_matter_parser/syntax_parser/multi_line_comment.rb, line 31
def build_regexp(start_delimiter, end_delimiter)
  /
  \A
  [[:space:]]*
  #{start_delimiter}
  [[:space:]]*
  ---
  (?<front_matter>.*?)
  ---
  [[:space:]]*
  #{end_delimiter}
  [[:blank:]]*$[\n\r]
  (?<content>.*)
  \z
  /mx
end