Sha256: 6665b22813f24a8c257b1db5ae48ad4a99562ca976597b8f00e036968245bd73

Contents?: true

Size: 831 Bytes

Versions: 1

Compression:

Stored size: 831 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
        "lib/templates/AnalyticsEvent.swift.erb"
      when :android
        "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

1 entries across 1 versions & 1 rubygems

Version Path
ai_tagger-0.1.5 lib/tagger/generator.rb