Class: ResumeTools::Period

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

Overview

Period

Represents a period in the section

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(props = {}) ⇒ Period


230
231
232
233
234
235
236
237
# File 'lib/resumetools/resume/resume.rb', line 230

def initialize(props={})
  @title = props[:title] || ""
  @location = props[:location] || ""
  @organization = props[:organization] || ""
  @dtstart = props[:dtstart] || nil
  @dtend = props[:dtend] || nil
  @items = Array.new
end

Instance Attribute Details

#dtendObject

Period end date


224
225
226
# File 'lib/resumetools/resume/resume.rb', line 224

def dtend
  @dtend
end

#dtstartObject

Period start date


221
222
223
# File 'lib/resumetools/resume/resume.rb', line 221

def dtstart
  @dtstart
end

#itemsObject (readonly)

List of items


227
228
229
# File 'lib/resumetools/resume/resume.rb', line 227

def items
  @items
end

#locationObject

Period location


215
216
217
# File 'lib/resumetools/resume/resume.rb', line 215

def location
  @location
end

#organizationObject

Period organization


218
219
220
# File 'lib/resumetools/resume/resume.rb', line 218

def organization
  @organization
end

#titleObject

Period title


212
213
214
# File 'lib/resumetools/resume/resume.rb', line 212

def title
  @title
end

Instance Method Details

#add_item(item) ⇒ Object

Adds an item


265
266
267
# File 'lib/resumetools/resume/resume.rb', line 265

def add_item(item)
  self.items << item
end

#create_item(props = {}, &block) ⇒ Object

Creates an item and adds it to the list


270
271
272
273
274
275
# File 'lib/resumetools/resume/resume.rb', line 270

def create_item(props={}, &block)
  item = Item.new(props)
  block.call(item) if block
  self.add_item(item)
  item
end

#has_dtend?Boolean


256
257
258
# File 'lib/resumetools/resume/resume.rb', line 256

def has_dtend?
  !self.dtend.blank?
end

#has_dtstart?Boolean


252
253
254
# File 'lib/resumetools/resume/resume.rb', line 252

def has_dtstart?
  !self.dtstart.blank?
end

#has_items?Boolean


260
261
262
# File 'lib/resumetools/resume/resume.rb', line 260

def has_items?
  !self.items.empty?
end

#has_location?Boolean


244
245
246
# File 'lib/resumetools/resume/resume.rb', line 244

def has_location?
  !self.location.blank?
end

#has_organization?Boolean


248
249
250
# File 'lib/resumetools/resume/resume.rb', line 248

def has_organization?
  !self.organization.blank?
end

#has_title?Boolean


240
241
242
# File 'lib/resumetools/resume/resume.rb', line 240

def has_title?
  !self.title.blank?
end

#lineObject

The period details in a single line


278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/resumetools/resume/resume.rb', line 278

def line
  elements = []
  elements << self.organization if self.has_organization?
  elements << self.location if self.has_location?
  if self.has_dtstart? && self.has_dtend?
    date = " (#{self.dtstart} - #{self.dtend})"
  elsif self.has_dtstart? || self.has_dtend?
    value = self.has_dtstart? ? self.dtstart : self.dtend
    date = " (#{value})"
  else
    date = ''
  end
  elements.join(", ").concat("#{date}")
end