lib/resumetools/resume/pdf.rb in virgild-resumetools-0.2.4.1 vs lib/resumetools/resume/pdf.rb in virgild-resumetools-0.2.5.0

- old
+ new

@@ -21,18 +21,19 @@ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. #++ +require "prawn" +require "prawn/format" +require "prawn/layout" +require "prawn/measurement_extensions" + module ResumeTools module Renderer module PDF - require "prawn" - require "prawn/format" - require "prawn/layout" - require "prawn/measurement_extensions" - + FONT_DIR = File.join(File.dirname(__FILE__), '..', '..', 'fonts') MARGINS = [1.0, 1.0, 1.0, 1.0] FONT_SIZES = { :default => 9, :header => 14, @@ -68,13 +69,13 @@ # Name pdf.text self.full_name, :style => :bold, :size => FONT_SIZES[:header], :align => :center # Contact info - pdf.text [self.address1, self.address2].join(", "), :align => :center - pdf.text [telephone, email].join(" • "), :align => :center - pdf.text url, :align => :center + self.header_lines.each do |line| + pdf.text line, :align => :center + end pdf.pad_bottom 20 do end # Sections @@ -108,18 +109,12 @@ pdf.pad_top(5) do # Period title pdf.pad_top(5) { pdf.text period.title, :style => :bold, :size => FONT_SIZES[:period] } # Period details - detail_line = [] - dates = print_date(period.dtstart, period.dtend) - detail_line << period.organization unless period.organization.blank? - detail_line << period.location unless period.location.blank? - detail_line << dates unless dates.blank? - pdf.span(pdf.bounds.width - 10, :position => 10) do - pdf.text(detail_line.join(" • "), :size => FONT_SIZES[:default]) + pdf.text(period.line, :size => FONT_SIZES[:default]) end # Period items unless period.items.empty? pdf.table period.items.map { |item| [" •", item.text] }, @@ -137,23 +132,13 @@ end end pdf.render end - - private - def print_date(dtstart, dtend) - if dtstart && dtend - dtstart + " - " + dtend - elsif dtstart && dtend.nil? - dtstart.strftime(DATE_FORMAT) - else - "" - end - end - end - end + + end #module PDF + end #module Renderer Resume.class_eval do include Renderer::PDF end -end +end #module ResumeTools \ No newline at end of file