Class: Scale::DSLBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/scale/dsl.rb

Instance Method Summary collapse

Constructor Details

#initialize(commands = []) ⇒ DSLBuilder

Returns a new instance of DSLBuilder.



24
25
26
# File 'lib/scale/dsl.rb', line 24

def initialize(commands = [])
  @commands = commands
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



28
29
30
# File 'lib/scale/dsl.rb', line 28

def method_missing(name, *args, &block)
  @commands.push(DSLCommand.new(name, args, block))
end

Instance Method Details

#to_xmlObject



32
33
34
35
36
37
38
# File 'lib/scale/dsl.rb', line 32

def to_xml
  svg = SVG.new
  @commands.each do |command|
    command.run(svg)
  end
  svg.to_xml
end