class FrontMatterParser::SyntaxParser::IndentationComment
Parser for syntaxes which use comments ended by indentation
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/indentation_comment.rb, line 24 def self.delimiters raise NotImplementedError end
@see Factorizable :nocov:
Source
# File lib/front_matter_parser/syntax_parser/indentation_comment.rb, line 13 def initialize @regexp = build_regexp(*self.class.delimiters) end
Public Instance Methods
Source
# File lib/front_matter_parser/syntax_parser/indentation_comment.rb, line 18 def call(string) string.match(regexp) end
@see SyntaxParser
Private Instance Methods
Source
# File lib/front_matter_parser/syntax_parser/indentation_comment.rb, line 31 def build_regexp(delimiter) / \A [[:space:]]* (?<multiline_comment_indentation>^[[:blank:]]*) #{delimiter} [[:space:]]* --- (?<front_matter>.*?) --- [[:blank:]]*$[\n\r] (?<content>.*) \z /mx end
rubocop:disable Metrics/MethodLength