Last active
August 29, 2015 14:16
-
-
Save fwilkens/eacc331a0ab291801404 to your computer and use it in GitHub Desktop.
Eval vs. Comp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.tempFiles = tempFiles # where are these tempfiles used? | |
evals.each do |e| #this makes no sense if there are >1 evals | |
return GetPDFBuffer(e,self.images[e._id.to_s],logo) | |
end | |
def GetPDFBuffer(eval, doc, logo) | |
_comps = [] | |
if(eval.comp_ids && (_comp_ids = eval.comp_ids.split(",")) && _comp_ids && _comp_ids.length>0) | |
_comps = Comp.find(_comp_ids) | |
end | |
# this block is being called for each eval, resulting in a new Eval Report document for each one, rather than a single document | |
r = EvalReport.new do | |
puts doc | |
write_content(eval, _comps, logo, doc) # images is a hash, subject is a hash, comparables is an array, logo is a filepath | |
start_new_page | |
end | |
return StringIO.new(r.render).read | |
end | |
# Comparable | |
# here the loop through comps is called within the ClosedSale block, so it works. | |
c = ClosedSale.new do | |
comps.each do |comp| | |
puts "rendering " + comp._id.to_s | |
_imgArray = _images[comp._id.to_s] | |
puts 'generating pdf report for '+ comp._id | |
puts _imgArray | |
write_content(comp, _imgArray, logo ) # => returns ClosedSaleObject which inherits from Prawn::Document | |
start_new_page | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment