Sha256: 71e8c28ad6df9a39b5d405463cbb703dada93ca538634c5469160fa5d87d663a

Contents?: true

Size: 602 Bytes

Versions: 6

Compression:

Stored size: 602 Bytes

Contents

# encoding: utf-8
module Filegen
  # Used to generate the template
  class ErbGenerator
    private

    attr_reader :data

    public

    # Create erb generator
    #
    # @param [Data] data
    #   The data class to be used within the template
    def initialize(data)
      @data = data
    end

    # Compile the template
    #
    # @param [IO] source
    #   The source template to be used
    # @param [IO] destination
    #   The output io handle
    def compile(source, destination)
      erb = ERB.new(source.read)
      destination.puts erb.result(data.instance_binding)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
filegen-0.2.3 lib/filegen/erb_generator.rb
filegen-0.2.2 lib/filegen/erb_generator.rb
filegen-0.2.1 lib/filegen/erb_generator.rb
filegen-0.2.0 lib/filegen/erb_generator.rb
filegen-0.1.2 lib/filegen/erb_generator.rb
filegen-0.1.1 lib/filegen/erb_generator.rb