Class: GrammarPlugin Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_grammar_builder/grammar_plugin.rb

Overview

This class is abstract.

Subclass GrammarLinter or GrammarTransform to implement a plugin

Direct Known Subclasses

GrammarLinter, GrammarTransform

Class Method Summary collapse

Class Method Details

.display_options(indent, options) ⇒ String

This method is abstract.

override this to display the options as they would be entered into source code

Note:

each option should be prepended with “\n,#{indent}”

Note:

only display the options that are unique to this plugin

display the options as they would appear in the source

Parameters:

  • indent (String)

    the spaces to indent each line width

  • options (Hash)

    all options passed to the pattern

Returns:

  • (String)

    the options as a string



21
22
23
24
25
26
27
28
29
# File 'lib/ruby_grammar_builder/grammar_plugin.rb', line 21

def self.display_options(indent, options) # rubocop:disable Lint/UnusedMethodArgument
    raise "Internal error: display_options called with no provided options" if options.empty?

    if self.options.empty?
        raise "Internal error: display_options called on a plugin that provides no options"
    end

    raise "GrammarPlugin::options implemented but GrammarPlugin::display_options has not been"
end

.optionsArray<Symbol>

Note:

the keys :grammar and :repository are reserved for passing grammar information

The options this plugin supports

Returns:

  • (Array<Symbol>)

    a list of symbols that represent keys that can be read by the plugin



9
10
11
# File 'lib/ruby_grammar_builder/grammar_plugin.rb', line 9

def self.options
    []
end