Sha256: cc7d08a10c12690b1d56b3bb3e59a8ccd9c770795ea2252acddd6d2c440fdf08

Contents?: true

Size: 1.23 KB

Versions: 10

Compression:

Stored size: 1.23 KB

Contents

module FbGraph
  class Work
    include Comparison

    attr_accessor :employer, :location, :position, :projects, :start_date, :end_date

    def initialize(attributes = {})
      if (employer = attributes[:employer])
        @employer = Page.new(employer.delete(:id), employer)
      end
      if (location = attributes[:location])
        @location = Page.new(location.delete(:id), location)
      end
      if (position = attributes[:position])
        @position = Page.new(position.delete(:id), position)
      end
      @projects = []
      if attributes[:projects]
        attributes[:projects].each do |project|
          @projects << Project.new(project.delete(:id), project)
        end
      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
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fb_graph-1.3.6 lib/fb_graph/work.rb
fb_graph-1.3.5 lib/fb_graph/work.rb
fb_graph-1.3.4 lib/fb_graph/work.rb
fb_graph-1.3.3 lib/fb_graph/work.rb
fb_graph-1.3.2 lib/fb_graph/work.rb
fb_graph-1.3.1 lib/fb_graph/work.rb
fb_graph-1.3.0 lib/fb_graph/work.rb
fb_graph-1.2.5 lib/fb_graph/work.rb
fb_graph-1.2.4 lib/fb_graph/work.rb
fb_graph-1.2.3 lib/fb_graph/work.rb