Class: Stylegen::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/stylegen/generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Generator

Returns a new instance of Generator.



8
9
10
# File 'lib/stylegen/generator.rb', line 8

def initialize(data)
  @data = Data.new(data)
end

Instance Method Details

#generateObject



12
13
14
15
16
17
18
19
# File 'lib/stylegen/generator.rb', line 12

def generate
  template_content = File.read(File.join(__dir__, "resources/template.swift.erb"))
  template = Template.new(template_content, @data)

  file = File.open(@data.output_path, "w")
  file << template.render
  file.close
end

#statsObject



21
22
23
# File 'lib/stylegen/generator.rb', line 21

def stats
  @stats ||= { output_path: @data.output_path, color_count: @data.colors.count }
end