Sha256: 99fd88112487dc4990a3bca14f588a20307b2e0f530515598a42d2100b3ad1e3

Contents?: true

Size: 833 Bytes

Versions: 4

Compression:

Stored size: 833 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
        "data/templates/AnalyticsEvent.swift.erb"
      when :android
        "data/templates/AnalyticsEvent.kt.erb"
      end
    end

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

    def output
      renderer.result(binding)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ai_tagger-0.1.3 lib/tagger/generator.rb
ai_tagger-0.1.2 lib/tagger/generator.rb
ai_tagger-0.1.1 lib/tagger/generator.rb
ai_tagger-0.1.0 lib/tagger/generator.rb