Sha256: 925eb94646168940c7391835d7da9eb92fa646f1fa5c86cb92b3f212e3535ac1

Contents?: true

Size: 1.45 KB

Versions: 101

Compression:

Stored size: 1.45 KB

Contents

module FbGraph
  class Work
    include Comparison

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

    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
  end
end

Version data entries

101 entries across 101 versions & 1 rubygems

Version Path
fb_graph-2.6.5 lib/fb_graph/work.rb
fb_graph-2.6.4 lib/fb_graph/work.rb
fb_graph-2.6.3 lib/fb_graph/work.rb
fb_graph-2.6.2 lib/fb_graph/work.rb
fb_graph-2.6.1 lib/fb_graph/work.rb
fb_graph-2.6.0 lib/fb_graph/work.rb
fb_graph-2.5.9 lib/fb_graph/work.rb
fb_graph-2.5.8 lib/fb_graph/work.rb
fb_graph-2.5.7 lib/fb_graph/work.rb
fb_graph-2.5.6 lib/fb_graph/work.rb
fb_graph-2.5.5 lib/fb_graph/work.rb
fb_graph-2.5.4 lib/fb_graph/work.rb
fb_graph-2.5.3 lib/fb_graph/work.rb
fb_graph-2.5.2 lib/fb_graph/work.rb
fb_graph-2.5.1 lib/fb_graph/work.rb
fb_graph-2.5.0 lib/fb_graph/work.rb
fb_graph-2.4.20 lib/fb_graph/work.rb
fb_graph-2.4.19 lib/fb_graph/work.rb
fb_graph-2.4.18 lib/fb_graph/work.rb
fb_graph-2.4.17 lib/fb_graph/work.rb