Sha256: b25065568760e1d9b82192789208bf7e978e7178fdb1dc9d7f60f9af82782a66

Contents?: true

Size: 1.49 KB

Versions: 18

Compression:

Stored size: 1.49 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.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
      @with = []
      if attributes[:with]
        attributes[:with].each do |user|
          @with << User.new(user.delete(: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

18 entries across 18 versions & 1 rubygems

Version Path
fb_graph-1.8.0 lib/fb_graph/work.rb
fb_graph-1.8.0.alpha2 lib/fb_graph/work.rb
fb_graph-1.7.5 lib/fb_graph/work.rb
fb_graph-1.8.0.alpha lib/fb_graph/work.rb
fb_graph-1.7.4 lib/fb_graph/work.rb
fb_graph-1.7.3 lib/fb_graph/work.rb
fb_graph-1.7.2 lib/fb_graph/work.rb
fb_graph-1.7.1 lib/fb_graph/work.rb
fb_graph-1.7.0 lib/fb_graph/work.rb
fb_graph-1.7.0.alpha2 lib/fb_graph/work.rb
fb_graph-1.6.9 lib/fb_graph/work.rb
fb_graph-1.7.0.alpha lib/fb_graph/work.rb
fb_graph-1.6.8 lib/fb_graph/work.rb
fb_graph-1.6.7 lib/fb_graph/work.rb
fb_graph-1.6.5 lib/fb_graph/work.rb
fb_graph-1.6.4 lib/fb_graph/work.rb
fb_graph-1.6.3 lib/fb_graph/work.rb
fb_graph-1.6.2 lib/fb_graph/work.rb