Class: ADF::ADFDoc

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

Instance Method Summary collapse

Constructor Details

#initializeADFDoc

Returns a new instance of ADFDoc.



35
36
37
# File 'lib/adf.rb', line 35

def initialize
  @prospects = []
end

Instance Method Details

#add_prospect(prospect) ⇒ Object



39
40
41
42
43
# File 'lib/adf.rb', line 39

def add_prospect(prospect)
  if not prospect.nil?
    @prospects.push prospect
  end
end

#to_xmlObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/adf.rb', line 45

def to_xml
  xml = Builder::XmlMarkup.new( :indent => 2 )
  xml.instruct! :xml, :encoding => "UTF-8"
  xml.instruct! :adf, :version => "1.0"
  xml.adf do |adf|
    @prospects.each do |prospect|
      xml.prospect do |p|
        p.request_date prospect.request_date
        p.customer do |customer|
          customer.contact do |contact|
            contact.name(prospect.customer_first, "part" => "first") if not prospect.customer_first.nil?
            contact.name(prospect.customer_last, "part" => "last") if not prospect.customer_last.nil?
            contact.phone(prospect.customer_phone) if not prospect.customer_phone.nil?
            contact.email(prospect.customer_email) if not prospect.customer_email.nil?
          end
        end
      end
    end
  end

  return xml.target!
end