class Resume::Resume::ResumeHandler

@private

Attributes

about[R]
jobs[R]
schools[R]
sections[R]

Public Class Methods

new() click to toggle source
# File lib/resume.rb, line 34
def initialize
  @about = {}
  @schools = []
  @jobs = []
  @sections = []

  [:name, :email, :address, :url, :phone].each do |field|
    self.class.class_eval do
      define_method field do |value|
        @about[field] = value
      end
    end
  end
end

Public Instance Methods

education(&block) click to toggle source
# File lib/resume.rb, line 49
def education &block
  sh = sub_handler [:school, :finished, :will_finish, :degree, :city]
  block.arity < 1 ? sh.instance_eval(&block) : block.call(sh)
  @schools << sh.data
end
job(&block) click to toggle source
# File lib/resume.rb, line 55
def job &block
  sh = sub_handler [:position, :employer, :city, :date, :description]
  block.arity < 1 ? sh.instance_eval(&block) : block.call(sh)
  @jobs << sh.data
end
section(&block) click to toggle source
# File lib/resume.rb, line 61
def section &block
  sh = sub_handler [:name, :text, :bullets]
  block.arity < 1 ? sh.instance_eval(&block) : block.call(sh)
  @sections << sh.data
end

Private Instance Methods

sub_handler(fields) click to toggle source

@private

# File lib/resume.rb, line 69
def sub_handler fields
  s = Class.new
  s.class_eval do
    attr_reader :data
    def initialize; @data = {}; end
    fields.each do |field|
      define_method field do |value|
        @data[field] = value
      end
    end
  end
  s.new
end