Class: GSGraph::Work
- Inherits:
-
Object
- Object
- GSGraph::Work
- Includes:
- Comparison
- Defined in:
- lib/gs_graph/work.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#employer ⇒ Object
Returns the value of attribute employer.
-
#end_date ⇒ Object
Returns the value of attribute end_date.
-
#location ⇒ Object
Returns the value of attribute location.
-
#position ⇒ Object
Returns the value of attribute position.
-
#projects ⇒ Object
Returns the value of attribute projects.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
-
#with ⇒ Object
Returns the value of attribute with.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Work
constructor
A new instance of Work.
Methods included from Comparison
Constructor Details
#initialize(attributes = {}) ⇒ Work
Returns a new instance of Work.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gs_graph/work.rb', line 7 def initialize(attributes = {}) @description = attributes[:description] if (employer = attributes[:employer]) @employer = Page.new(employer[:id], employer) end if (location = attributes[:location]) @location = Page.new(location[:id], location) end if (position = attributes[:position]) @position = Page.new(position[:id], position) end @projects = [] if attributes[:projects] attributes[:projects].each do |project| @projects << Project.new(project[:id], project) end end @with = [] if attributes[:with] attributes[:with].each do |user| @with << User.new(user[:id], user) end end if attributes[:start_date] && attributes[:start_date] != '0000-00' year, month = attributes[:start_date].split('-').collect(&:to_i) @start_date = if month.blank? || month == 0 Date.new(year) else Date.new(year, month) end end if attributes[:end_date] && attributes[:end_date] != '0000-00' year, month = attributes[:end_date].split('-').collect(&:to_i) @end_date = if month.blank? || month == 0 Date.new(year) else Date.new(year, month) end end end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/gs_graph/work.rb', line 5 def description @description end |
#employer ⇒ Object
Returns the value of attribute employer.
5 6 7 |
# File 'lib/gs_graph/work.rb', line 5 def employer @employer end |
#end_date ⇒ Object
Returns the value of attribute end_date.
5 6 7 |
# File 'lib/gs_graph/work.rb', line 5 def end_date @end_date end |
#location ⇒ Object
Returns the value of attribute location.
5 6 7 |
# File 'lib/gs_graph/work.rb', line 5 def location @location end |
#position ⇒ Object
Returns the value of attribute position.
5 6 7 |
# File 'lib/gs_graph/work.rb', line 5 def position @position end |
#projects ⇒ Object
Returns the value of attribute projects.
5 6 7 |
# File 'lib/gs_graph/work.rb', line 5 def projects @projects end |
#start_date ⇒ Object
Returns the value of attribute start_date.
5 6 7 |
# File 'lib/gs_graph/work.rb', line 5 def start_date @start_date end |
#with ⇒ Object
Returns the value of attribute with.
5 6 7 |
# File 'lib/gs_graph/work.rb', line 5 def with @with end |