Sha256: 80daa75ffe1ba4c45281b91f899e8b909d358cbd0f43a4392d69eac3524e90ff

Contents?: true

Size: 861 Bytes

Versions: 13

Compression:

Stored size: 861 Bytes

Contents

module Tagger
  class Generator
    attr_accessor :events, :platform

    def initialize(events, platform)
      @events = events
      @platform = platform
    end

    def generate(output_location)
      File.write("#{output_location}/#{output_file_name}", output)
    end

  private

    def template
      File.open(template_file, "r").read
    end

    def output_file_name
      case @platform
      when :ios
        "AnalyticsEvent.swift"
      when :android
        "AnalyticsEvent.kt"
      end
    end

    def template_file
      case @platform
      when :ios
        "#{Tagger.root}/lib/templates/AnalyticsEvent.swift.erb"
      when :android
        "#{Tagger.root}/lib/templates/AnalyticsEvent.kt.erb"
      end
    end

    def renderer
      ERB.new(template, nil, '-')
    end

    def output
      renderer.result(binding)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ai_tagger-0.4.4 lib/tagger/generator.rb
ai_tagger-0.4.3 lib/tagger/generator.rb
ai_tagger-0.4.2 lib/tagger/generator.rb
ai_tagger-0.4.1 lib/tagger/generator.rb
ai_tagger-0.4.0 lib/tagger/generator.rb
ai_tagger-0.3.1 lib/tagger/generator.rb
ai_tagger-0.3.0 lib/tagger/generator.rb
ai_tagger-0.2.1 lib/tagger/generator.rb
ai_tagger-0.2.0 lib/tagger/generator.rb
ai_tagger-0.1.10 lib/tagger/generator.rb
ai_tagger-0.1.9 lib/tagger/generator.rb
ai_tagger-0.1.8 lib/tagger/generator.rb
ai_tagger-0.1.7 lib/tagger/generator.rb