class FrontMatterParser::SyntaxParser::MultiLineComment
Parser for syntaxes which use end and finish comment delimiters
Attributes
@!attribute [r] regexp A regexp that returns two groups: front_matter and content
Public Class Methods
Source
# File lib/front_matter_parser/syntax_parser/multi_line_comment.rb, line 24 def self.delimiters raise NotImplementedError end
@see Factorizable :nocov:
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
Source
# File lib/front_matter_parser/syntax_parser/multi_line_comment.rb, line 18 def call(string) string.match(regexp) end
@see SyntaxParser
Private Instance Methods
Source
# 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
rubocop:disable Metrics/MethodLength