Module: FrontMatterParser::SyntaxParser::Factorizable

Included in:
IndentationComment, MultiLineComment, SingleLineComment
Defined in:
lib/front_matter_parser/syntax_parser/factorizable.rb

Overview

This is just a helper to allow creating syntax parsers with a more terse syntax, without the need of explicitly creating descendant classes for the most general cases. See FrontMatterParser::SyntaxParser for examples in use.

Instance Method Summary collapse

Instance Method Details

#[](*delimiters) ⇒ Object

used by the parser

added which returns an array with given comment delimiters

Parameters:

  • delimiters (String)

    Splat arguments with all comment delimiters

Returns:

  • (Object)

    A base class of self with a delimiters class method



14
15
16
17
# File 'lib/front_matter_parser/syntax_parser/factorizable.rb', line 14

def [](*delimiters)
  delimiters = delimiters.map { |delimiter| Regexp.escape(delimiter) }
  create_base_class(delimiters)
end