Class: FbGraph::Work

Inherits:
Object
  • Object
show all
Includes:
Comparison
Defined in:
lib/fb_graph/work.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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
# File 'lib/fb_graph/work.rb', line 7

def initialize(attributes = {})
  if (employer = attributes[:employer])
    @employer = FbGraph::Page.new(employer.delete(:id), employer)
  end
  if (location = attributes[:location])
    @location = FbGraph::Page.new(location.delete(:id), location)
  end
  if (position = attributes[:position])
    @position = FbGraph::Page.new(position.delete(:id), position)
  end
  if attributes[:start_date] && attributes[:start_date] != '0000-00'
    year, month = attributes[:start_date].split('-').collect(&:to_i)
    @start_date = if 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 == 0
      Date.new(year)
    else
      Date.new(year, month)
    end
  end
end

Instance Attribute Details

#employerObject

Returns the value of attribute employer.



5
6
7
# File 'lib/fb_graph/work.rb', line 5

def employer
  @employer
end

#end_dateObject

Returns the value of attribute end_date.



5
6
7
# File 'lib/fb_graph/work.rb', line 5

def end_date
  @end_date
end

#locationObject

Returns the value of attribute location.



5
6
7
# File 'lib/fb_graph/work.rb', line 5

def location
  @location
end

#positionObject

Returns the value of attribute position.



5
6
7
# File 'lib/fb_graph/work.rb', line 5

def position
  @position
end

#start_dateObject

Returns the value of attribute start_date.



5
6
7
# File 'lib/fb_graph/work.rb', line 5

def start_date
  @start_date
end