Module Citrus::Grammar

  1. lib/citrus.rb

Inclusion of this module into another extends the receiver with the grammar helper methods in GrammarMethods. Although this module does not actually provide any methods, constants, or variables to modules that include it, the mere act of inclusion provides a useful lookup mechanism to determine if a module is in fact a grammar.

Methods

public class

  1. included
  2. new

Included modules

  1. Grammar

Public class methods

included (mod)

Extends all modules that +include Grammar+ with GrammarMethods and exposes Module#include.

[show source]
     # File lib/citrus.rb, line 368
368:     def self.included(mod)
369:       mod.extend(GrammarMethods)
370:       # Expose #include so it can be called publicly.
371:       class << mod; public :include end
372:     end
new (&block)

Creates a new anonymous module that includes Grammar. If a block is provided, it is module_eval‘d in the context of the new module. Grammars created with this method may be assigned a name by being assigned to some constant, e.g.:

MyGrammar = Citrus::Grammar.new {}
[show source]
     # File lib/citrus.rb, line 360
360:     def self.new(&block)
361:       mod = Module.new { include Grammar }
362:       mod.module_eval(&block) if block
363:       mod
364:     end