module Citrus::Grammar

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.

Public Class Methods

included(mod) click to toggle source

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

# File lib/citrus.rb, line 367
def self.included(mod)
  mod.extend(GrammarMethods)
  # Expose #include so it can be called publicly.
  class << mod; public :include end
end
new(&block) click to toggle source

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 {}
# File lib/citrus.rb, line 359
def self.new(&block)
  mod = Module.new { include Grammar }
  mod.module_eval(&block) if block
  mod
end