Class: ResumeTools::Period
- Inherits:
-
Object
- Object
- ResumeTools::Period
- Defined in:
- lib/resumetools/resume/resume.rb
Overview
Period
Represents a period in the section
Instance Attribute Summary collapse
-
#dtend ⇒ Object
Period end date.
-
#dtstart ⇒ Object
Period start date.
-
#items ⇒ Object
readonly
List of items.
-
#location ⇒ Object
Period location.
-
#organization ⇒ Object
Period organization.
-
#title ⇒ Object
Period title.
Instance Method Summary collapse
-
#add_item(item) ⇒ Object
Adds an item.
-
#create_item(props = {}, &block) ⇒ Object
Creates an item and adds it to the list.
- #has_dtend? ⇒ Boolean
- #has_dtstart? ⇒ Boolean
- #has_items? ⇒ Boolean
- #has_location? ⇒ Boolean
- #has_organization? ⇒ Boolean
- #has_title? ⇒ Boolean
-
#initialize(props = {}) ⇒ Period
constructor
A new instance of Period.
-
#line ⇒ Object
The period details in a single line.
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
#dtend ⇒ Object
Period end date
221 222 223 |
# File 'lib/resumetools/resume/resume.rb', line 221 def dtend @dtend end |
#dtstart ⇒ Object
Period start date
218 219 220 |
# File 'lib/resumetools/resume/resume.rb', line 218 def dtstart @dtstart end |
#items ⇒ Object (readonly)
List of items
224 225 226 |
# File 'lib/resumetools/resume/resume.rb', line 224 def items @items end |
#location ⇒ Object
Period location
212 213 214 |
# File 'lib/resumetools/resume/resume.rb', line 212 def location @location end |
#organization ⇒ Object
Period organization
215 216 217 |
# File 'lib/resumetools/resume/resume.rb', line 215 def organization @organization end |
#title ⇒ Object
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
253 254 255 |
# File 'lib/resumetools/resume/resume.rb', line 253 def has_dtend? !self.dtend.blank? end |
#has_dtstart? ⇒ Boolean
249 250 251 |
# File 'lib/resumetools/resume/resume.rb', line 249 def has_dtstart? !self.dtstart.blank? end |
#has_items? ⇒ Boolean
257 258 259 |
# File 'lib/resumetools/resume/resume.rb', line 257 def has_items? !self.items.empty? end |
#has_location? ⇒ Boolean
241 242 243 |
# File 'lib/resumetools/resume/resume.rb', line 241 def has_location? !self.location.blank? end |
#has_organization? ⇒ Boolean
245 246 247 |
# File 'lib/resumetools/resume/resume.rb', line 245 def has_organization? !self.organization.blank? end |
#has_title? ⇒ Boolean
237 238 239 |
# File 'lib/resumetools/resume/resume.rb', line 237 def has_title? !self.title.blank? end |
#line ⇒ Object
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 |