Class: Cuenote::Api::XmlBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/cuenote/api/xml_builder.rb

Instance Method Summary collapse

Constructor Details

#initializeXmlBuilder

Returns a new instance of XmlBuilder.



6
7
8
9
# File 'lib/cuenote/api/xml_builder.rb', line 6

def initialize
  @builder = ::Builder::XmlMarkup.new
  @commands = []
end

Instance Method Details

#add_command(command, id = nil, params = nil) ⇒ Object



11
12
13
14
# File 'lib/cuenote/api/xml_builder.rb', line 11

def add_command command, id=nil, params=nil
  id, params = [nil, id] if id && !params && Hash === id
  @commands << [command, id, params]
end

#buildObject



16
17
18
19
20
21
22
# File 'lib/cuenote/api/xml_builder.rb', line 16

def build
  @builder.forecast do |forecast|
    @commands.each do |command, id, params|
      build_command command, id, params
    end
  end
end