Class: FaviconMaker::Generator

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/favicon_maker/generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGenerator

Returns a new instance of Generator.



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

def initialize
  @creators = {}
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



15
16
17
# File 'lib/favicon_maker/generator.rb', line 15

def config
  @config
end

#creatorsObject

Returns the value of attribute creators.



16
17
18
# File 'lib/favicon_maker/generator.rb', line 16

def creators
  @creators
end

#finished_blockObject

Returns the value of attribute finished_block.



17
18
19
# File 'lib/favicon_maker/generator.rb', line 17

def finished_block
  @finished_block
end

Instance Method Details

#each_icon(&block) ⇒ Object



33
34
35
# File 'lib/favicon_maker/generator.rb', line 33

def each_icon(&block)
  @finished_block = block
end

#from(template_filename, options = "", &block) ⇒ Object



29
30
31
# File 'lib/favicon_maker/generator.rb', line 29

def from(template_filename, options="", &block)
  creators[template_filename] = [options, block]
end

#setup(&block) ⇒ Object



25
26
27
# File 'lib/favicon_maker/generator.rb', line 25

def setup(&block)
  @config = Docile.dsl_eval(MakerConfig.new, &block)
end

#startObject



37
38
39
40
41
42
43
# File 'lib/favicon_maker/generator.rb', line 37

def start
  creators.each do |template_filename, options_and_block|
    template_file = File.join(template_dir, template_filename)
    options, creator_block = *options_and_block
    Docile.dsl_eval(Creator.new(template_file, output_dir, options, finished_block), &creator_block).run
  end
end