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

Returns a new instance of Period.



227
228
229
230
231
232
233
234
# File 'lib/resumetools/resume/resume.rb', line 227

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



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

def dtend
  @dtend
end

#dtstartObject

Period start date



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

def dtstart
  @dtstart
end

#itemsObject (readonly)

List of items



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

def items
  @items
end

#locationObject

Period location



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

def location
  @location
end

#organizationObject

Period organization



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

def organization
  @organization
end

#titleObject

Period title



209
210
211
# File 'lib/resumetools/resume/resume.rb', line 209

def title
  @title
end

Instance Method Details

#add_item(item) ⇒ Object

Adds an item



262
263
264
# File 'lib/resumetools/resume/resume.rb', line 262

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

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

Creates an item and adds it to the list



267
268
269
270
271
272
# File 'lib/resumetools/resume/resume.rb', line 267

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

#has_dtend?Boolean

Returns:

  • (Boolean)


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

def has_dtend?
  !self.dtend.blank?
end

#has_dtstart?Boolean

Returns:

  • (Boolean)


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

def has_dtstart?
  !self.dtstart.blank?
end

#has_items?Boolean

Returns:

  • (Boolean)


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

def has_items?
  !self.items.empty?
end

#has_location?Boolean

Returns:

  • (Boolean)


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

def has_location?
  !self.location.blank?
end

#has_organization?Boolean

Returns:

  • (Boolean)


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

def has_organization?
  !self.organization.blank?
end

#has_title?Boolean

Returns:

  • (Boolean)


237
238
239
# File 'lib/resumetools/resume/resume.rb', line 237

def has_title?
  !self.title.blank?
end

#lineObject

The period details in a single line



275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/resumetools/resume/resume.rb', line 275

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