Sha256: ab9d0210fde5b49b8698cf6ea5daee29912e983ac268b1a20cca26b091cdb2fd

Contents?: true

Size: 708 Bytes

Versions: 3

Compression:

Stored size: 708 Bytes

Contents

require "pp"

module Antelope
  class Generator

    # Generates an output file, mainly for debugging.  Included always
    # as a generator for a grammar.
    class Output < Generator

      # Defines singleton method for every mod that the grammar passed
      # to the generator.
      #
      # @see Generator#initialize
      def initialize(*)
        super
        mods.each do |k, v|
          define_singleton_method (k) { v }
        end
      end

      # Actually performs the generation.  Uses the template in
      # output.erb, and generates the file `<file>.output`.
      #
      # @return [void]
      def generate
        template "output.erb", "#{file}.output"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
antelope-0.1.1 lib/antelope/generator/output.rb
antelope-0.1.0 lib/antelope/generator/output.rb
antelope-0.0.1 lib/antelope/generator/output.rb