class ResumeTools::Exporter
Public Class Methods
new(resume)
click to toggle source
# File lib/resumetools/resume/export.rb, line 4 def initialize(resume) @resume = resume @content = "" end
Public Instance Methods
run()
click to toggle source
# File lib/resumetools/resume/export.rb, line 9 def run reset! write_header blank_line @resume.sections.each_with_index do |section, n| write_section section blank_line if (n < @resume.sections.length - 1) end @content end
Private Instance Methods
blank_line()
click to toggle source
# File lib/resumetools/resume/export.rb, line 106 def blank_line @content << "\n" end
line(text)
click to toggle source
# File lib/resumetools/resume/export.rb, line 110 def line(text) @content << text << "\n" end
reset!()
click to toggle source
# File lib/resumetools/resume/export.rb, line 24 def reset! @content = "" end
write_contact_info(info)
click to toggle source
# File lib/resumetools/resume/export.rb, line 37 def write_contact_info(info) # TODO: make this smoother case info when :full_name line "#N #{@resume.full_name}" unless @resume.full_name.blank? when :address1 line "#A #{@resume.address1}" if @resume.has_address1? when :address2 line "#A #{@resume.address2}" if @resume.has_address2? when :telephone line "#T #{@resume.telephone}" if @resume.has_telephone? when :email line "#E #{@resume.email}" if @resume.has_email? when :url line "#U #{@resume.url}" if @resume.has_url? end end
write_dates(period)
click to toggle source
# File lib/resumetools/resume/export.rb, line 92 def write_dates(period) text = "" if period.has_dtstart? && period.has_dtend? text = "#{period.dtstart} to #{period.dtend}" elsif period.has_dtstart? && !period.has_dtend? text = period.dtstart elsif !period.has_dtstart? && period.has_dtend? text = period.dtend else text = "" end line ">D #{text}" unless text.blank? end
write_header()
click to toggle source
# File lib/resumetools/resume/export.rb, line 28 def write_header write_contact_info :full_name write_contact_info :address1 write_contact_info :address2 write_contact_info :telephone write_contact_info :email write_contact_info :url end
write_item(item)
click to toggle source
# File lib/resumetools/resume/export.rb, line 75 def write_item(item) line "- #{item.text}" end
write_para(para)
click to toggle source
# File lib/resumetools/resume/export.rb, line 69 def write_para(para) line "---" line para line "---" end
write_period(period)
click to toggle source
# File lib/resumetools/resume/export.rb, line 79 def write_period(period) line "+ #{period.title}" line ">O #{period.organization}" if period.has_organization? line ">L #{period.location}" if period.has_location? write_dates(period) if period.has_items? period.items.each_with_index do |item, n| write_item item end end end
write_section(section)
click to toggle source
# File lib/resumetools/resume/export.rb, line 55 def write_section(section) line "= #{section.title}" write_para(section.para) if section.has_para? section.items.each_with_index do |item, n| write_item item end section.periods.each_with_index do |period, n| write_period period blank_line if (n < section.periods.length - 1) end end